Here are the examples of the csharp api System.Collections.Generic.ICollection.Add(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
161 Examples
19
Source : AnnotatedPointMarker.cs
with MIT License
from ABTSoftware
with MIT License
from ABTSoftware
public override void MoveTo(IRenderContext2D context, double x, double y, int index)
{
if (IsInBounds(x, y))
{
_dataPointIndexes.Add(index);
}
base.MoveTo(context, x, y, index);
}
19
Source : FamiliarsUtils.cs
with GNU General Public License v3.0
from aedenthorn
with GNU General Public License v3.0
from aedenthorn
public static void monsterDrop(Familiar familiar, Monster monster, Farmer owner)
{
IList<int> objects = monster.objectsToDrop;
if (Game1.player.isWearingRing(526))
{
string result = "";
Game1.content.Load<Dictionary<string, string>>("Data\\Monsters").TryGetValue(monster.Name, out result);
if (result != null && result.Length > 0)
{
string[] objectsSplit = result.Split(new char[]
{
'/'
})[6].Split(new char[]
{
' '
});
for (int i = 0; i < objectsSplit.Length; i += 2)
{
if (Game1.random.NextDouble() < Convert.ToDouble(objectsSplit[i + 1]))
{
objects.Add(Convert.ToInt32(objectsSplit[i]));
}
}
}
}
if (objects == null || objects.Count == 0)
return;
int objectToAdd = objects[Game1.random.Next(objects.Count)];
if (objectToAdd < 0)
{
familiar.currentLocation.debris.Add(Game1.createItemDebris(new StardewValley.Object(Math.Abs(objectToAdd), Game1.random.Next(1, 4)), familiar.position, Game1.random.Next(4)));
}
else
{
familiar.currentLocation.debris.Add(Game1.createItemDebris(new StardewValley.Object(Math.Abs(objectToAdd), 1), familiar.position, Game1.random.Next(4)));
}
}
19
Source : ConvexHullHelper.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
public static void GetConvexHull(IList<Vector3> points, IList<int> outputTriangleIndices)
{
var rawPoints = CommonResources.GetVectorList();
var rawIndices = CommonResources.GetIntList();
rawPoints.AddRange(points);
GetConvexHull(rawPoints, rawIndices);
CommonResources.GiveBack(rawPoints);
for (int i = 0; i < rawIndices.Count; i++)
{
outputTriangleIndices.Add(rawIndices[i]);
}
CommonResources.GiveBack(rawIndices);
}
19
Source : ConvexHullHelper.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
public static void GetConvexHull(IList<Vector3> points, IList<int> outputTriangleIndices, IList<Vector3> outputSurfacePoints)
{
var rawPoints = CommonResources.GetVectorList();
var rawIndices = CommonResources.GetIntList();
rawPoints.AddRange(points);
GetConvexHull(rawPoints, rawIndices, outputSurfacePoints);
CommonResources.GiveBack(rawPoints);
for (int i = 0; i < rawIndices.Count; i++)
{
outputTriangleIndices.Add(rawIndices[i]);
}
CommonResources.GiveBack(rawIndices);
}
19
Source : MeshBoundingBoxTree.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
internal override void GetOverlaps(ref BoundingBox boundingBox, IList<int> outputOverlappedElements)
{
//Our parent already tested the bounding box. All that's left is to add myself to the list.
outputOverlappedElements.Add(LeafIndex);
}
19
Source : MeshBoundingBoxTree.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
internal override void GetOverlaps(ref BoundingSphere boundingSphere, IList<int> outputOverlappedElements)
{
outputOverlappedElements.Add(LeafIndex);
}
19
Source : MeshBoundingBoxTree.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
internal override void GetOverlaps(ref Ray ray, float maximumLength, IList<int> outputOverlappedElements)
{
outputOverlappedElements.Add(LeafIndex);
}
19
Source : CollectionUtils.cs
with MIT License
from akaskela
with MIT License
from akaskela
private static IList<int> GetDimensions(IList values, int dimensionsCount)
{
IList<int> dimensions = new List<int>();
IList currentArray = values;
while (true)
{
dimensions.Add(currentArray.Count);
// don't keep calculating dimensions for arrays inside the value array
if (dimensions.Count == dimensionsCount)
{
break;
}
if (currentArray.Count == 0)
{
break;
}
object v = currentArray[0];
if (v is IList)
{
currentArray = (IList)v;
}
else
{
break;
}
}
return dimensions;
}
19
Source : CollectionUtils.cs
with MIT License
from akaskela
with MIT License
from akaskela
public static Array ToMultidimensionalArray(IList values, Type type, int rank)
{
IList<int> dimensions = GetDimensions(values, rank);
while (dimensions.Count < rank)
{
dimensions.Add(0);
}
Array multidimensionalArray = Array.CreateInstance(type, dimensions.ToArray());
CopyFromJaggedToMultidimensionalArray(values, multidimensionalArray, new int[0]);
return multidimensionalArray;
}
19
Source : TypeNameParser.cs
with GNU General Public License v3.0
from anydream
with GNU General Public License v3.0
from anydream
IList<TSpec> ReadTSpecs() {
var tspecs = new List<TSpec>();
while (true) {
SkipWhite();
switch (PeekChar()) {
case '[': // SZArray, Array, or GenericInst
ReadChar();
SkipWhite();
var peeked = PeekChar();
if (peeked == ']') {
// SZ array
Verify(ReadChar() == ']', "Expected ']'");
tspecs.Add(SZArraySpec.Instance);
}
else if (peeked == '*' || peeked == ',' || peeked == '-' || char.IsDigit((char)peeked)) {
// Array
var arraySpec = new ArraySpec();
arraySpec.rank = 0;
while (true) {
SkipWhite();
int c = PeekChar();
if (c == '*')
ReadChar();
else if (c == ',' || c == ']') {
}
else if (c == '-' || char.IsDigit((char)c)) {
int lower = ReadInt32();
uint? size;
SkipWhite();
Verify(ReadChar() == '.', "Expected '.'");
Verify(ReadChar() == '.', "Expected '.'");
if (PeekChar() == '.') {
ReadChar();
size = null;
}
else {
SkipWhite();
if (PeekChar() == '-') {
int upper = ReadInt32();
Verify(upper >= lower, "upper < lower");
size = (uint)(upper - lower + 1);
Verify(size.Value != 0 && size.Value <= 0x1FFFFFFF, "Invalid size");
}
else {
uint upper = ReadUInt32();
long lsize = (long)upper - (long)lower + 1;
Verify(lsize > 0 && lsize <= 0x1FFFFFFF, "Invalid size");
size = (uint)lsize;
}
}
if (arraySpec.lowerBounds.Count == arraySpec.rank)
arraySpec.lowerBounds.Add(lower);
if (size.HasValue && arraySpec.sizes.Count == arraySpec.rank)
arraySpec.sizes.Add(size.Value);
}
else
Verify(false, "Unknown char");
arraySpec.rank++;
SkipWhite();
if (PeekChar() != ',')
break;
ReadChar();
}
Verify(ReadChar() == ']', "Expected ']'");
tspecs.Add(arraySpec);
}
else {
// Generic args
var ginstSpec = new GenericInstSpec();
while (true) {
SkipWhite();
peeked = PeekChar();
bool needSeperators = peeked == '[';
if (peeked == ']')
break;
Verify(!needSeperators || ReadChar() == '[', "Expected '['");
ginstSpec.args.Add(ReadType(needSeperators));
SkipWhite();
Verify(!needSeperators || ReadChar() == ']', "Expected ']'");
SkipWhite();
if (PeekChar() != ',')
break;
ReadChar();
}
Verify(ReadChar() == ']', "Expected ']'");
tspecs.Add(ginstSpec);
}
break;
case '&': // ByRef
ReadChar();
tspecs.Add(ByRefSpec.Instance);
break;
case '*': // Ptr
ReadChar();
tspecs.Add(PtrSpec.Instance);
break;
default:
return tspecs;
}
}
}
19
Source : ProducerTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
//[Repeat(25)]
[ConnectionSetup(null,"c1")]
[SessionSetup("c1","s1")]
[TopicSetup("s1","t1",Name = "nms.topic.test")]
[ConsumerSetup("s1","t1","drain")]
public void TestMultipleProducerCreateAndSend(
[Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)]
MsgDeliveryMode mode
)
{
const int MSG_TTL_MILLIS = 8500; // 8.5 secs
const int NUM_MSGS = 200;
const int NUM_PRODUCERS = 5;
const string MSG_ID_KEY = "MsgIndex";
const string PRODUCER_ID_KEY = "ProducerIndex";
const string PRODUCER_INDEXED_ID_KEY = "ProducerIndexedMsgId";
bool persistent = mode.Equals(MsgDeliveryMode.Persistent);
bool useMsgId = !persistent;
int msgIdWindow = 0;
string failureErr = null;
IMessageProducer producer = null;
IList<IMessageProducer> producers = null;
IList<int> lastProducerIndexedIds = null;
try
{
using (IConnection connection = this.GetConnection("c1"))
using (ISession session = this.GetSession("s1"))
using (IDestination destination = this.GetDestination("t1"))
using (IMessageConsumer drain = this.GetConsumer("drain"))
{
lastProducerIndexedIds = new List<int>();
MessageListener ackCallback = CreateListener(NUM_MSGS);
drain.Listener += (message) =>
{
if (failureErr == null)
{
ackCallback(message);
int id = message.Properties.GetInt(PRODUCER_INDEXED_ID_KEY);
int prodIndex = message.Properties.GetInt(PRODUCER_ID_KEY);
int lastId = lastProducerIndexedIds[prodIndex];
int advancedMsgs = id - lastId;
if (id < lastId)
{
failureErr = string.Format(
"Received message out of order." +
" Received, sent from producer {0} msg id {1} where last msg id {2}",
prodIndex,
id,
lastId
);
this.waiter.Set();
}
else if(persistent && advancedMsgs > 1)
{
failureErr = string.Format(
"Persistent Messages where drop." +
" Received, sent from producer {0} msg id {1} where last msg id {2}",
prodIndex,
id,
lastId
);
this.waiter.Set();
}
else
{
lastProducerIndexedIds[prodIndex] = id;
if (advancedMsgs > 1 && (Logger.IsInfoEnabled || Logger.IsDebugEnabled))
{
Logger.Info(string.Format(
"{0} Messages dropped for producer {1} from message id {2}",
advancedMsgs, prodIndex, lastId
));
}
msgIdWindow += advancedMsgs;
if (!persistent && msgIdWindow == NUM_MSGS)
{
this.waiter.Set();
}
}
}
};
connection.ExceptionListener += DefaultExceptionListener;
producers = new List<IMessageProducer>();
for (int i = 0; i < NUM_PRODUCERS; i++)
{
try
{
producer = session.CreateProducer(destination);
}
catch (Exception ex)
{
this.PrintTestFailureAndreplacedert(this.GetMethodName(), "Failed to Created Producer " + i, ex);
}
producer.DeliveryMode = mode;
producer.DisableMessageID = !useMsgId;
producer.TimeToLive = TimeSpan.FromMilliseconds(MSG_TTL_MILLIS);
producers.Add(producer);
lastProducerIndexedIds.Add(-1);
}
connection.Start();
replacedert.AreEqual(NUM_PRODUCERS, producers.Count, "Did not create all producers.");
replacedert.IsNull(asyncEx,
"Exception Listener Called While creating producers. With exception {0}.",
asyncEx);
ITextMessage msg = session.CreateTextMessage();
int producerIndex = -1;
for (int i = 0; i < NUM_MSGS; i++)
{
msg.Text = "Index:" + i;
msg.Properties[MSG_ID_KEY] = i;
msg.Properties[PRODUCER_INDEXED_ID_KEY] = i / NUM_PRODUCERS;
producerIndex = i % NUM_PRODUCERS;
msg.Properties[PRODUCER_ID_KEY] = producerIndex;
producers[producerIndex].Send(msg);
}
replacedert.IsNull(asyncEx, "Exception Listener Called While sending messages. With exception {0}.", asyncEx);
replacedert.IsTrue(waiter.WaitOne(TIMEOUT),
"Failed to received all messages in {0}ms. Received {1} of {2} messages",
TIMEOUT, msgCount, NUM_MSGS);
replacedert.IsNull(failureErr,
"Received replacedertion failure from IMessageConsumer message Listener. Failure : {0}",
failureErr ?? "");
if (persistent)
{
replacedert.AreEqual(NUM_MSGS, msgCount,
"Receive unexpected from messages sent. Message Window {0}", msgIdWindow);
}
else
{
int missedMsgs = (msgIdWindow - msgCount);
replacedert.AreEqual(NUM_MSGS, msgIdWindow,
"Failed to receive all messages." +
" Received {0} of {1} messages, with missed messages {2}, in {3}ms",
msgCount, NUM_MSGS, missedMsgs, TIMEOUT
);
if(missedMsgs > 0)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
const string SEPARATOR = ", ";
for(int i=0; i<NUM_PRODUCERS; i++)
{
sb.AppendFormat("Last received Producer {0} message id {1}{2}", i, lastProducerIndexedIds[i], SEPARATOR);
}
sb.Length = sb.Length - SEPARATOR.Length;
Logger.Warn(string.Format("Did not receive all Non Persistent messages. Received {0} of {1} messages. Where last received message ids = [{2}]", msgCount, NUM_MSGS, sb.ToString()));
}
}
replacedert.IsNull(asyncEx, "Exception Listener Called While receiveing messages. With exception {0}.", asyncEx);
//
// Some brokers are sticklers for detail and actually honor the
// batchable flag that AMQPnetLite sets on all published messages. As
// a result all messages can be long received before the published
// messages are acknowledged. So to avoid a hand full of
// amqp:message:released outcomes, just pause a few seconds before
// closing the producer
System.Threading.Thread.Sleep(3000);
}
}
catch (Exception e)
{
this.PrintTestFailureAndreplacedert(this.GetMethodName(), "Unexpected Exception.", e);
}
finally
{
if(producers != null)
{
foreach(IMessageProducer p in producers)
{
p?.Close();
p?.Dispose();
}
producers.Clear();
}
}
}
19
Source : Mesh.cs
with MIT License
from AximoGames
with MIT License
from AximoGames
public void AddFace(params int[] indicies)
{
var face = new InternalMeshFace()
{
StartIndex = Indicies.Count,
Count = indicies.Length,
};
InternalMeshFaces.Add(face);
for (var i = 0; i < indicies.Length; i++)
Indicies.Add(indicies[i]);
}
19
Source : Mesh.cs
with MIT License
from AximoGames
with MIT License
from AximoGames
public void AddFace(IList<int> indicies)
{
var face = new InternalMeshFace()
{
StartIndex = Indicies.Count,
Count = indicies.Count,
};
InternalMeshFaces.Add(face);
for (var i = 0; i < indicies.Count; i++)
Indicies.Add(indicies[i]);
}
19
Source : Mesh.cs
with MIT License
from AximoGames
with MIT License
from AximoGames
public void AddFaceAndMaterial(int materialId, params int[] indicies)
{
var face = new InternalMeshFace()
{
StartIndex = Indicies.Count,
Count = indicies.Length,
MaterialId = materialId,
};
// TODO: Improve. Track every matrialID.
MaterialIds.Add(materialId);
InternalMeshFaces.Add(face);
for (var i = 0; i < indicies.Length; i++)
Indicies.Add(indicies[i]);
}
19
Source : GLRenderSystem.Render.cs
with GNU Lesser General Public License v2.1
from axiom3d
with GNU Lesser General Public License v2.1
from axiom3d
[OgreVersion(1, 7, 2790)]
protected void BindVertexElementToGpu(VertexElement elem, HardwareVertexBuffer vertexBuffer, int vertexStart,
IList<int> attribsBound, IList<int> instanceAttribsBound)
{
IntPtr pBufferData;
var hwGlBuffer = (GLHardwareVertexBuffer)vertexBuffer;
if (currentCapabilities.HasCapability(Graphics.Capabilities.VertexBuffer))
{
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, hwGlBuffer.GLBufferID);
pBufferData = BUFFER_OFFSET(elem.Offset);
}
else
{
// ReSharper disable PossibleInvalidCastException
pBufferData = ((GLDefaultHardwareVertexBuffer)(vertexBuffer)).DataPtr(elem.Offset);
// ReSharper restore PossibleInvalidCastException
}
if (vertexStart != 0)
{
pBufferData = pBufferData.Offset(vertexStart * vertexBuffer.VertexSize);
}
var sem = elem.Semantic;
var mulreplacedexturing = Capabilities.TextureUnitCount > 1;
var isCustomAttrib = false;
if (this.currentVertexProgram != null)
{
isCustomAttrib = this.currentVertexProgram.IsAttributeValid(sem, (uint)elem.Index);
if (hwGlBuffer.IsInstanceData)
{
var attrib = this.currentVertexProgram.AttributeIndex(sem, (uint)elem.Index);
glVertexAttribDivisor((int)attrib, hwGlBuffer.InstanceDataStepRate);
instanceAttribsBound.Add((int)attrib);
}
}
// Custom attribute support
// tangents, binormals, blendweights etc always via this route
// builtins may be done this way too
if (isCustomAttrib)
{
var attrib = this.currentVertexProgram.AttributeIndex(sem, (uint)elem.Index);
var typeCount = VertexElement.GetTypeCount(elem.Type);
var normalised = Gl.GL_FALSE;
switch (elem.Type)
{
case VertexElementType.Color:
case VertexElementType.Color_ABGR:
case VertexElementType.Color_ARGB:
// Because GL takes these as a sequence of single unsigned bytes, count needs to be 4
// VertexElement::getTypeCount treats them as 1 (RGBA)
// Also need to normalise the fixed-point data
typeCount = 4;
normalised = Gl.GL_TRUE;
break;
default:
break;
}
Gl.glVertexAttribPointerARB(attrib, typeCount, GLHardwareBufferManager.GetGLType(elem.Type), normalised,
vertexBuffer.VertexSize, pBufferData);
Gl.glEnableVertexAttribArrayARB(attrib);
attribsBound.Add((int)attrib);
}
else
{
// fixed-function & builtin attribute support
switch (sem)
{
case VertexElementSemantic.Position:
Gl.glVertexPointer(VertexElement.GetTypeCount(elem.Type), GLHardwareBufferManager.GetGLType(elem.Type),
vertexBuffer.VertexSize, pBufferData);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
break;
case VertexElementSemantic.Normal:
Gl.glNormalPointer(GLHardwareBufferManager.GetGLType(elem.Type), vertexBuffer.VertexSize, pBufferData);
Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY);
break;
case VertexElementSemantic.Diffuse:
Gl.glColorPointer(4, GLHardwareBufferManager.GetGLType(elem.Type), vertexBuffer.VertexSize, pBufferData);
Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);
break;
case VertexElementSemantic.Specular:
if (this.GLEW_EXT_secondary_color)
{
Gl.glSecondaryColorPointerEXT(4, GLHardwareBufferManager.GetGLType(elem.Type), vertexBuffer.VertexSize,
pBufferData);
Gl.glEnableClientState(Gl.GL_SECONDARY_COLOR_ARRAY);
}
break;
case VertexElementSemantic.TexCoords:
if (this.currentVertexProgram != null)
{
// Programmable pipeline - direct UV replacedignment
Gl.glClientActiveTextureARB(Gl.GL_TEXTURE0 + elem.Index);
Gl.glTexCoordPointer(VertexElement.GetTypeCount(elem.Type), GLHardwareBufferManager.GetGLType(elem.Type),
vertexBuffer.VertexSize, pBufferData);
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
}
else
{
// fixed function matching to units based on tex_coord_set
for (var i = 0; i < disabledTexUnitsFrom; i++)
{
// Only set this texture unit's texcoord pointer if it
// is supposed to be using this element's index
if (this.texCoordIndex[i] != elem.Index || i >= this._fixedFunctionTextureUnits)
{
continue;
}
if (mulreplacedexturing)
{
Gl.glClientActiveTextureARB(Gl.GL_TEXTURE0 + i);
}
Gl.glTexCoordPointer(VertexElement.GetTypeCount(elem.Type), GLHardwareBufferManager.GetGLType(elem.Type),
vertexBuffer.VertexSize, pBufferData);
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
}
}
break;
default:
break;
}
} // isCustomAttrib
}
19
Source : MaterialCheckboxGroup.xaml.cs
with MIT License
from Baseflow
with MIT License
from Baseflow
private void CheckboxSelected(bool isSelected, int index)
{
try
{
if (isSelected && SelectedIndices.All(s => s != index))
{
SelectedIndices.Add(index);
OnSelectedIndicesChanged(SelectedIndices);
}
else if (!isSelected && SelectedIndices.Any(s => s == index))
{
SelectedIndices.Remove(index);
OnSelectedIndicesChanged(SelectedIndices);
}
}
catch (NotSupportedException)
{
throw new NotSupportedException("Please use a collection type that has no fixed size for the property SelectedIndices");
}
}
19
Source : SignalRTests.cs
with MIT License
from Beffyman
with MIT License
from Beffyman
[Fact(Timeout = Constants.TEST_TIMEOUT)]
public async Task CounterChannelTest()
{
using (var endpoint = new JsonServerInfo())
{
var hub = new ChatHubConnectionBuilder(endpoint.Server.BaseAddress, null,
config =>
{
config.HttpMessageHandlerFactory = _ => endpoint.Server.CreateHandler();
})
.Build();
int count = 100;
int delay = 20;
IList<int> results = new List<int>();
await hub.StartAsync(endpoint.TimeoutToken);
var channel = await hub.StreamCounterAsync(count, delay, endpoint.TimeoutToken);
while (await channel.WaitToReadAsync(endpoint.TimeoutToken))
{
while (channel.TryRead(out int item))
{
results.Add(item);
}
}
await hub.StopAsync(endpoint.TimeoutToken);
replacedert.Equal(count, results.Count());
}
}
19
Source : QueryLexer.cs
with MIT License
from bleroy
with MIT License
from bleroy
private void EscapeCharacter()
{
_escapeCharPositions.Add(_pos - 1);
_pos++;
}
19
Source : ParseTreePatternMatcher.cs
with MIT License
from Butjok
with MIT License
from Butjok
internal virtual IList<Chunk> Split(string pattern)
{
int p = 0;
int n = pattern.Length;
IList<Chunk> chunks = new List<Chunk>();
// find all start and stop indexes first, then collect
IList<int> starts = new List<int>();
IList<int> stops = new List<int>();
while (p < n)
{
if (p == pattern.IndexOf(escape + start, p))
{
p += escape.Length + start.Length;
}
else
{
if (p == pattern.IndexOf(escape + stop, p))
{
p += escape.Length + stop.Length;
}
else
{
if (p == pattern.IndexOf(start, p))
{
starts.Add(p);
p += start.Length;
}
else
{
if (p == pattern.IndexOf(stop, p))
{
stops.Add(p);
p += stop.Length;
}
else
{
p++;
}
}
}
}
}
// System.out.println("");
// System.out.println(starts);
// System.out.println(stops);
if (starts.Count > stops.Count)
{
throw new ArgumentException("unterminated tag in pattern: " + pattern);
}
if (starts.Count < stops.Count)
{
throw new ArgumentException("missing start tag in pattern: " + pattern);
}
int ntags = starts.Count;
for (int i = 0; i < ntags; i++)
{
if (starts[i] >= stops[i])
{
throw new ArgumentException("tag delimiters out of order in pattern: " + pattern);
}
}
// collect into chunks now
if (ntags == 0)
{
string text = Sharpen.Runtime.Substring(pattern, 0, n);
chunks.Add(new TextChunk(text));
}
if (ntags > 0 && starts[0] > 0)
{
// copy text up to first tag into chunks
string text = Sharpen.Runtime.Substring(pattern, 0, starts[0]);
chunks.Add(new TextChunk(text));
}
for (int i_1 = 0; i_1 < ntags; i_1++)
{
// copy inside of <tag>
string tag = Sharpen.Runtime.Substring(pattern, starts[i_1] + start.Length, stops[i_1]);
string ruleOrToken = tag;
string label = null;
int colon = tag.IndexOf(':');
if (colon >= 0)
{
label = Sharpen.Runtime.Substring(tag, 0, colon);
ruleOrToken = Sharpen.Runtime.Substring(tag, colon + 1, tag.Length);
}
chunks.Add(new TagChunk(label, ruleOrToken));
if (i_1 + 1 < ntags)
{
// copy from end of <tag> to start of next
string text = Sharpen.Runtime.Substring(pattern, stops[i_1] + stop.Length, starts[i_1 + 1]);
chunks.Add(new TextChunk(text));
}
}
if (ntags > 0)
{
int afterLastTag = stops[ntags - 1] + stop.Length;
if (afterLastTag < n)
{
// copy text from end of last tag to end
string text = Sharpen.Runtime.Substring(pattern, afterLastTag, n);
chunks.Add(new TextChunk(text));
}
}
// strip out the escape sequences from text chunks but not tags
for (int i_2 = 0; i_2 < chunks.Count; i_2++)
{
Chunk c = chunks[i_2];
if (c is TextChunk)
{
TextChunk tc = (TextChunk)c;
string unescaped = tc.Text.Replace(escape, string.Empty);
if (unescaped.Length < tc.Text.Length)
{
chunks.Set(i_2, new TextChunk(unescaped));
}
}
}
return chunks;
}
19
Source : IntervalSet.cs
with MIT License
from Butjok
with MIT License
from Butjok
public virtual IList<int> ToList()
{
IList<int> values = new ArrayList<int>();
int n = intervals.Count;
for (int i = 0; i < n; i++)
{
Interval I = intervals[i];
int a = I.a;
int b = I.b;
for (int v = a; v <= b; v++)
{
values.Add(v);
}
}
return values;
}
19
Source : EnumerableExtensions.cs
with GNU General Public License v2.0
from Caeden117
with GNU General Public License v2.0
from Caeden117
public static IList<int> AllIndexOf(this string text, string str, bool standardizeUpperCase = true,
StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase)
{
IList<int> allIndexOf = new List<int>();
var newSource = standardizeUpperCase ? text.ToUpper() : text;
var newStr = standardizeUpperCase ? str.ToUpper() : str;
var index = newSource.IndexOf(newStr, comparisonType);
while (index != -1)
{
allIndexOf.Add(index);
index = newSource.IndexOf(newStr, index + newStr.Length, comparisonType);
}
return allIndexOf;
}
19
Source : ConstantPool.cs
with GNU General Public License v3.0
from Cm-lang
with GNU General Public License v3.0
from Cm-lang
public static int AllocateStringConstant(string value, int len)
{
var index = StringConstants.IndexOf(value);
if (-1 != index) return index;
StringConstants.Add(value);
StringConstantLengths.Add(len);
return StringConstants.Count - 1;
}
19
Source : CollectionUtils.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
private static IList<int> GetDimensions(IList values)
{
IList<int> dimensions = new List<int>();
IList currentArray = values;
while (true)
{
dimensions.Add(currentArray.Count);
if (currentArray.Count == 0)
break;
object v = currentArray[0];
if (v is IList)
currentArray = (IList)v;
else
break;
}
return dimensions;
}
19
Source : CollectionUtils.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
public static Array ToMultidimensionalArray(IList values, Type type, int rank)
{
IList<int> dimensions = GetDimensions(values);
while (dimensions.Count < rank)
{
dimensions.Add(0);
}
Array multidimensionalArray = Array.CreateInstance(type, dimensions.ToArray());
CopyFromJaggedToMultidimensionalArray(values, multidimensionalArray, new int[0]);
return multidimensionalArray;
}
19
Source : MapRenderable3D.cs
with MIT License
from csinkers
with MIT License
from csinkers
void SortingUpdate()
{
using var _ = PerfTracker.FrameEvent("5.1 Update tilemap (sorting)");
foreach (var list in _tilesByDistance.Values)
list.Clear();
var cameraTilePosition = Resolve<ICamera>().Position;
var map = Resolve<IMapManager>().Current;
if (map != null)
cameraTilePosition /= map.TileSize;
int cameraTileX = (int)cameraTilePosition.X;
int cameraTileY = (int)cameraTilePosition.Y;
for (int j = 0; j < _logicalMap.Height; j++)
{
for (int i = 0; i < _logicalMap.Width; i++)
{
int distance = Math.Abs(j - cameraTileY) + Math.Abs(i - cameraTileX);
if(!_tilesByDistance.TryGetValue(distance, out var list))
{
list = new List<int>();
_tilesByDistance[distance] = list;
}
int index = j * _logicalMap.Width + i;
list.Add(index);
}
}
int order = 0;
foreach (var distance in _tilesByDistance.OrderByDescending(x => x.Key).ToList())
{
if (distance.Value.Count == 0)
{
_tilesByDistance.Remove(distance.Key);
continue;
}
foreach (var index in distance.Value)
{
SetTile(index, order, _frameCount);
order++;
}
}
}
19
Source : DequeTests.cs
with MIT License
from cuteant
with MIT License
from cuteant
[Fact]
public void Add_IsAddToBack()
{
var deque1 = new Deque<int>(new[] { 1, 2 });
var deque2 = new Deque<int>(new[] { 1, 2 });
((ICollection<int>)deque1).Add(3);
deque2.AddLast(3);
replacedert.Equal(deque1, deque2);
}
19
Source : Solution.cs
with MIT License
from cwetanow
with MIT License
from cwetanow
public static IList<int> RotateList(IList<int> list, int k)
{
for (int i = 0; i < k; i++)
{
var element = list.First();
list.RemoveAt(0);
list.Add(element);
}
return list;
}
19
Source : TestIntAllocator.cs
with MIT License
from CymaticLabs
with MIT License
from CymaticLabs
[Test]
public void TestRandomAllocation()
{
int repeatCount = 10000;
int range = 100;
IList<int> allocated = new List<int>();
IntAllocator intAllocator = new IntAllocator(0, range);
Random rand = new Random();
while (repeatCount-- > 0)
{
if (rand.Next(2) == 0)
{
int a = intAllocator.Allocate();
if (a > -1)
{
replacedert.False(allocated.Contains(a));
allocated.Add(a);
}
}
else if (allocated.Count > 0)
{
int a = allocated[0];
intAllocator.Free(a);
allocated.RemoveAt(0);
}
}
}
19
Source : TestIntAllocator.cs
with MIT License
from CymaticLabs
with MIT License
from CymaticLabs
[Test]
public void TestAllocateAll()
{
int range = 100;
IList<int> allocated = new List<int>();
IntAllocator intAllocator = new IntAllocator(0, range);
for (int i=0; i <= range; i++)
{
int a = intAllocator.Allocate();
replacedert.AreNotEqual(-1, a);
replacedert.False(allocated.Contains(a));
allocated.Add(a);
}
}
19
Source : AbstractTexturePacker.cs
with MIT License
from DanzaG
with MIT License
from DanzaG
protected IEnumerable<int> GetMeshTextureIndices(TRMesh[] meshes)
{
ISet<int> textureIndices = new SortedSet<int>();
foreach (TRMesh mesh in meshes)
{
foreach (TRFace4 rect in mesh.TexturedRectangles)
{
textureIndices.Add(rect.Texture);
}
foreach (TRFace3 tri in mesh.TexturedTriangles)
{
textureIndices.Add(tri.Texture);
}
}
return textureIndices;
}
19
Source : ColourTransportHandler.cs
with MIT License
from DanzaG
with MIT License
from DanzaG
private ISet<int> GetAllColourIndices(TRMesh[] meshes)
{
ISet<int> colourIndices = new SortedSet<int>();
foreach (TRMesh mesh in meshes)
{
foreach (TRFace4 rect in mesh.ColouredRectangles)
{
colourIndices.Add(rect.Texture >> 8);
}
foreach (TRFace3 tri in mesh.ColouredTriangles)
{
colourIndices.Add(tri.Texture >> 8);
}
}
return colourIndices;
}
19
Source : EntitySetTask.cs
with MIT License
from DataObjects-NET
with MIT License
from DataObjects-NET
private static void AddResultColumnIndexes(ICollection<int> indexes, IndexInfo index,
int columnIndexOffset)
{
for (var i = 0; i < index.Columns.Count; i++) {
var column = index.Columns[i];
if (PrefetchHelper.IsFieldToBeLoadedByDefault(column.Field)) {
indexes.Add(i + columnIndexOffset);
}
}
}
19
Source : NeovimRpcClient.cs
with GNU General Public License v2.0
from dontpanic92
with GNU General Public License v2.0
from dontpanic92
private void NotificationDispatcher(string name, IList<MsgPack.MessagePackObject> rawEvents)
{
if (name != "redraw")
{
Trace.WriteLine("Unexpected notification received" + name);
return;
}
List<TRedrawEvent> events = new List<TRedrawEvent>();
foreach (var rawEvent in rawEvents)
{
var cmd = rawEvent.AsList();
var eventName = cmd[0].replacedtring();
// Debug.WriteLine("event: " + string.Join(" ", cmd));
switch (eventName)
{
case "set_replacedle":
{
var replacedle = cmd[1].AsList()[0].replacedtringUtf8();
events.Add(this.factory.CreateSetreplacedleEvent(replacedle));
break;
}
case "set_icon":
{
var replacedle = cmd[1].AsList()[0].replacedtringUtf8();
events.Add(this.factory.CreateSetIconreplacedleEvent(replacedle));
break;
}
case "mode_info_set":
{
var args = cmd[1].AsList();
var cursorStyleEnabled = args[0].AsBoolean();
var mode = args[1].AsList().Select(
item => (IDictionary<string, string>)item.AsDictionary().ToDictionary(
k => k.Key.replacedtringUtf8(),
v => v.Value.ToString())).ToList();
events.Add(this.factory.CreateModeInfoSetEvent(cursorStyleEnabled, mode));
break;
}
case "mode_change":
{
var args = cmd[1].AsList();
var modeName = args[0].replacedtringUtf8();
var index = args[1].AsInt32();
events.Add(this.factory.CreateModeChangeEvent(modeName, index));
break;
}
case "cursor_goto":
{
var list = cmd[1].AsList();
uint row = list[0].AsUInt32();
uint col = list[1].AsUInt32();
events.Add(this.factory.CreateCursorGotoEvent(row, col));
break;
}
case "put":
{
IList<int?> result = new List<int?>();
for (int i = 1; i < cmd.Count; i++)
{
var ch = string.Join(string.Empty, cmd[i].AsEnumerable().Select(t => t.replacedtring()));
int? codepoint = null;
if (ch != string.Empty)
{
codepoint = char.ConvertToUtf32(ch, 0);
}
result.Add(codepoint);
}
events.Add(this.factory.CreatePutEvent(result));
break;
}
case "clear":
{
events.Add(this.factory.CreateClearEvent());
break;
}
case "eol_clear":
{
events.Add(this.factory.CreateEolClearEvent());
break;
}
case "resize":
{
var list = cmd[1].AsList();
uint col = list[0].AsUInt32();
uint row = list[1].AsUInt32();
events.Add(this.factory.CreateResizeEvent(row, col));
break;
}
case "highlight_set":
{
var dict = cmd[1].AsList()[0].AsDictionary();
int? foreground = TryGetValueFromDictionary(dict, "foreground")?.AsInt32();
int? background = TryGetValueFromDictionary(dict, "background")?.AsInt32();
int? special = TryGetValueFromDictionary(dict, "special")?.AsInt32();
bool reverse = TryGetValueFromDictionary(dict, "reverse")?.AsBoolean() == true;
bool italic = TryGetValueFromDictionary(dict, "italic")?.AsBoolean() == true;
bool bold = TryGetValueFromDictionary(dict, "bold")?.AsBoolean() == true;
bool underline = TryGetValueFromDictionary(dict, "underline")?.AsBoolean() == true;
bool undercurl = TryGetValueFromDictionary(dict, "undercurl")?.AsBoolean() == true;
events.Add(this.factory.CreateHightlightSetEvent(
foreground,
background,
special,
reverse,
italic,
bold,
underline,
undercurl));
break;
}
case "update_fg":
{
var color = cmd[1].AsList()[0].AsInt32();
events.Add(this.factory.CreateUpdateFgEvent(color));
break;
}
case "update_bg":
{
var color = cmd[1].AsList()[0].AsInt32();
events.Add(this.factory.CreateUpdateBgEvent(color));
break;
}
case "update_sp":
{
var color = cmd[1].AsList()[0].AsInt32();
events.Add(this.factory.CreateUpdateSpEvent(color));
break;
}
case "set_scroll_region":
{
var list = cmd[1].AsList();
events.Add(this.factory.CreateSetScrollRegionEvent(
list[0].AsInt32(),
list[1].AsInt32(),
list[2].AsInt32(),
list[3].AsInt32()));
break;
}
case "scroll":
{
int count = cmd[1].AsList()[0].AsInt32();
events.Add(this.factory.CreateScrollEvent(count));
break;
}
case "option_set":
{
for (int i = 1; i < cmd.Count; i++)
{
var list = cmd[i].AsList();
events.Add(this.factory.CreateOptionSetEvent(list[0].replacedtring(), list[1].ToString()));
}
break;
}
}
}
this.Redraw?.Invoke(events);
}
19
Source : ZeroQueueSizeTest.cs
with Apache License 2.0
from eaba
with Apache License 2.0
from eaba
[Fact]
public void TestZeroQueueSizeMessageRedelivery()
{
const string topic = "testZeroQueueSizeMessageRedelivery";
var config = new ConsumerConfigBuilder<int>()
.Topic(topic)
.SubscriptionName("sub")
.ReceiverQueueSize(0)
.SubscriptionType(SubType.Shared)
.AckTimeout(1, TimeUnit.SECONDS);
var consumer = _client.NewConsumer(ISchema<object>.Int32, config);
var pBuilder = new ProducerConfigBuilder<int>()
.Topic(topic)
.EnableBatching(false);
var producer = _client.NewProducer(ISchema<object>.Int32, pBuilder);
const int messages = 10;
for(int i = 0; i < messages; i++)
{
producer.Send(i);
}
ISet<int> receivedMessages = new HashSet<int>();
for(int i = 0; i < messages * 2; i++)
{
receivedMessages.Add(consumer.Receive().Value);
}
replacedert.Equal(receivedMessages.Count, messages);
consumer.Close();
producer.Close();
}
19
Source : ZeroQueueSizeTest.cs
with Apache License 2.0
from eaba
with Apache License 2.0
from eaba
[Fact]
public void TestZeroQueueSizeMessageRedeliveryForListener()
{
string topic = $"testZeroQueueSizeMessageRedeliveryForListener-{DateTime.Now.Ticks}";
const int messages = 10;
CountdownEvent latch = new CountdownEvent(messages * 2);
ISet<int> receivedMessages = new HashSet<int>();
var config = new ConsumerConfigBuilder<int>()
.Topic(topic)
.SubscriptionName("sub")
.ReceiverQueueSize(0)
.SubscriptionType(SubType.Shared)
.AckTimeout(1, TimeUnit.SECONDS)
.MessageListener(new MessageListener<int>((consumer, msg) =>
{
try
{
receivedMessages.Add(msg.Value);
}
finally
{
latch.Signal();
}
}, null));
var consumer = _client.NewConsumer(ISchema<object>.Int32, config);
var pBuilder = new ProducerConfigBuilder<int>()
.Topic(topic)
.EnableBatching(false);
var producer = _client.NewProducer(ISchema<object>.Int32, pBuilder);
for(int i = 0; i < messages; i++)
{
producer.Send(i);
}
latch.Wait();
replacedert.Equal(receivedMessages.Count, messages);
consumer.Close();
producer.Close();
}
19
Source : CollectionUtils.cs
with Apache License 2.0
from elastic
with Apache License 2.0
from elastic
private static IList<int> GetDimensions(IList values, int dimensionsCount)
{
IList<int> dimensions = new List<int>();
var currentArray = values;
while (true)
{
dimensions.Add(currentArray.Count);
// don't keep calculating dimensions for arrays inside the value array
if (dimensions.Count == dimensionsCount) break;
if (currentArray.Count == 0) break;
var v = currentArray[0];
if (v is IList list)
currentArray = list;
else
break;
}
return dimensions;
}
19
Source : CollectionUtils.cs
with Apache License 2.0
from elastic
with Apache License 2.0
from elastic
public static Array ToMultidimensionalArray(IList values, Type type, int rank)
{
var dimensions = GetDimensions(values, rank);
while (dimensions.Count < rank) dimensions.Add(0);
var multidimensionalArray = Array.CreateInstance(type, dimensions.ToArray());
CopyFromJaggedToMultidimensionalArray(values, multidimensionalArray, ArrayEmpty<int>());
return multidimensionalArray;
}
19
Source : CollectionExtensionsTests.cs
with Apache License 2.0
from elastic
with Apache License 2.0
from elastic
[Fact]
public void IsEmpty_IList_test()
{
IList<int> list = new List<int>();
list.IsEmpty().Should().BeTrue();
list.Add(123);
list.IsEmpty().Should().BeFalse();
list.Clear();
list.IsEmpty().Should().BeTrue();
}
19
Source : CollectionExtensionsTests.cs
with Apache License 2.0
from elastic
with Apache License 2.0
from elastic
[Fact]
public void IsEmpty_ICollection_test()
{
ICollection<int> list = new List<int>();
list.IsEmpty().Should().BeTrue();
list.Add(123);
list.IsEmpty().Should().BeFalse();
list.Clear();
list.IsEmpty().Should().BeTrue();
}
19
Source : EventSourceSink.cs
with MIT License
from enricosada
with MIT License
from enricosada
private void RaiseErrorEvent(object sender, BuildErrorEventArgs buildEvent)
{
// Keep track of build submissions that have logged errors. If there is no build context, add BuildEventContext.InvalidSubmissionId.
BuildSubmissionIdsThatHaveLoggedErrors.Add(buildEvent?.BuildEventContext?.SubmissionId ?? BuildEventContext.InvalidSubmissionId);
if (ErrorRaised != null)
{
try
{
ErrorRaised(sender, buildEvent);
}
catch (LoggerException)
{
// if a logger has failed politely, abort immediately
// first unregister all loggers, since other loggers may receive remaining events in unexpected orderings
// if a fellow logger is throwing in an event handler.
this.UnregisterAllEventHandlers();
throw;
}
catch (Exception exception)
{
// first unregister all loggers, since other loggers may receive remaining events in unexpected orderings
// if a fellow logger is throwing in an event handler.
this.UnregisterAllEventHandlers();
if (ExceptionHandling.IsCriticalException(exception))
{
throw;
}
InternalLoggerException.Throw(exception, buildEvent, "FatalErrorWhileLogging", false);
}
}
RaiseAnyEvent(sender, buildEvent);
}
19
Source : Player.Ammo.cs
with MIT License
from Facepunch
with MIT License
from Facepunch
public bool SetAmmo( AmmoType type, int amount )
{
var iType = (int)type;
if ( !Host.IsServer ) return false;
if ( Ammo == null ) return false;
while ( Ammo.Count <= iType )
{
Ammo.Add( 0 );
}
Ammo[(int)type] = amount;
return true;
}
19
Source : ReadOnlySetTests.cs
with MIT License
from Faithlife
with MIT License
from Faithlife
[Test]
public void ModifyingCollectionThrows()
{
ICollection<int> set = m_set;
replacedert.Throws<NotSupportedException>(() => set.Add(4));
replacedert.Throws<NotSupportedException>(() => set.Remove(1));
replacedert.Throws<NotSupportedException>(() => set.Clear());
}
19
Source : RichTextAreaSink.cs
with GNU General Public License v3.0
from FanTranslatorsInternational
with GNU General Public License v3.0
from FanTranslatorsInternational
private void LogInternal(Color logColor, string message)
{
var text = message + '\n';
// Cap log if necessary
if (_loggedPositions.Count > _limit)
{
_richTextArea.Buffer.Delete(new Range<int>(_loggedPositions[0], _loggedLengths[0] - 1));
var firstLength = _loggedLengths[0];
_loggedPositions.RemoveAt(0);
_loggedLengths.RemoveAt(0);
for (var i = 0; i < _loggedPositions.Count; i++)
_loggedPositions[i] -= firstLength;
}
// Update text buffer
var position = _loggedPositions.Count <= 0 ? 0 : _loggedPositions.Last() + _loggedLengths.Last();
_loggedPositions.Add(position);
_richTextArea.Buffer.Insert(position, text);
_loggedLengths.Add(_richTextArea.Text.Length - position - 1);
_richTextArea.Buffer.SetForeground(new Range<int>(position, _richTextArea.Text.Length - 1), logColor);
}
19
Source : ListPoolAsIListOfTSourceTests.cs
with MIT License
from faustodavid
with MIT License
from faustodavid
public override void Add_items_when_capacity_is_full_then_buffer_autogrow()
{
using ListPool<int> listPool = new ListPool<int>(128);
IList<int> sut = listPool;
List<int> expectedItems = s_fixture.CreateMany<int>(listPool.Capacity * 2).ToList();
foreach (int expectedItem in expectedItems)
{
sut.Add(expectedItem);
}
replacedert.Equal(expectedItems.Count, sut.Count);
replacedert.True(expectedItems.All(expectedItem => sut.Contains(expectedItem)));
}
19
Source : FindString.xaml.cs
with BSD 2-Clause "Simplified" License
from fcarver
with BSD 2-Clause "Simplified" License
from fcarver
private void startSearch()
{
_marker.ClearMarks();
_foundOffsets.Clear();
string word = _edtSearchText.Text;
if (string.IsNullOrEmpty(word))
{
return;
}
int startIdx = 0;
while (true)
{
int idx = _editor.Text.IndexOf(word, startIdx, StringComparison.InvariantCultureIgnoreCase);
if (idx < 0)
{
break;
}
startIdx = idx + 1;
_foundOffsets.Add(idx);
_marker.AddOffsetToMark(new MarkBackgroundRenderer.Mark
{
Offset = idx,
Length = word.Length,
Brush = new SolidColorBrush(Colors.Yellow)
});
}
}
19
Source : PrimeFactor.cs
with MIT License
from garora
with MIT License
from garora
public static IList<int?> Generate(int number)
{
IList<int?> primes = new List<int?>();
for (var candidate = 2; number > 1; candidate++)
for (; number%candidate == 0; number /= candidate)
primes.Add(candidate);
return primes;
}
19
Source : Solver.cs
with MIT License
from getbucket
with MIT License
from getbucket
private void CheckForRootRequiresProblems(bool ignorePlantForm)
{
foreach (var job in jobs)
{
if (job.Command == JobCommand.Update)
{
var packages = pool.WhatProvides(job.PackageName, job.Constraint);
foreach (var package in packages)
{
if (installedMap.ContainsKey(package.Id))
{
updateMap.Add(package.Id);
}
}
}
else if (job.Command == JobCommand.UpdateAll)
{
foreach (var item in installedMap)
{
updateMap.Add(item.Key);
}
}
else if (job.Command == JobCommand.Install)
{
if (ignorePlantForm && Regex.IsMatch(job.PackageName, RepositoryPlatform.RegexPlatform))
{
continue;
}
if (pool.WhatProvides(job.PackageName, job.Constraint).Length > 0)
{
continue;
}
var problem = new Problem(pool);
problem.AddRule(new RuleGeneric(Array.Empty<int>(), Reason.Undefined, null, job));
problems.Add(problem);
}
}
}
19
Source : RuleSetGenerator.cs
with MIT License
from getbucket
with MIT License
from getbucket
protected static ICollection<int> CreateWhitelistFromPackages(Pool pool, IPackage[] packages, ICollection<int> whitelist = null)
{
whitelist = whitelist ?? new HashSet<int>();
var queue = new Queue<IPackage>();
foreach (var package in packages)
{
queue.Enqueue(package);
while (queue.Count > 0)
{
var workPackage = queue.Dequeue();
if (whitelist.Contains(workPackage.Id))
{
continue;
}
whitelist.Add(workPackage.Id);
foreach (var link in workPackage.GetRequires())
{
var possibleRequires = pool.WhatProvides(link.GetTarget(), link.GetConstraint(), true);
Array.ForEach(possibleRequires, (requires) => queue.Enqueue(requires));
}
var obsoleteProviders = pool.WhatProvides(workPackage.GetName(), null, true);
foreach (var provider in obsoleteProviders)
{
if (provider == workPackage)
{
continue;
}
if (workPackage is PackageAlias packageAlias
&& packageAlias.GetAliasOf() == provider)
{
queue.Enqueue(provider);
}
}
}
}
return whitelist;
}
19
Source : Solver.cs
with MIT License
from getbucket
with MIT License
from getbucket
private void CheckForRootRequiresProblems(bool ignorePlantForm)
{
foreach (var job in jobs)
{
if (job.Command == JobCommand.Update)
{
var packages = pool.WhatProvides(job.PackageName, job.Constraint);
foreach (var package in packages)
{
if (installedMap.ContainsKey(package.Id))
{
updateMap.Add(package.Id);
}
}
}
else if (job.Command == JobCommand.UpdateAll)
{
foreach (var item in installedMap)
{
updateMap.Add(item.Key);
}
}
else if (job.Command == JobCommand.Install)
{
if (ignorePlantForm && Regex.IsMatch(job.PackageName, RepositoryPlatform.RegexPlatform))
{
continue;
}
if (pool.WhatProvides(job.PackageName, job.Constraint).Length > 0)
{
continue;
}
var problem = new Problem(pool);
problem.AddRule(new RuleGeneric(Array.Empty<int>(), Reason.Undefined, null, job));
problems.Add(problem);
}
}
}
19
Source : Utils.cs
with MIT License
from godotengine
with MIT License
from godotengine
public static string ReadMultiCaretTestCode(string testCode, ICollection<int> mustPreplacedCaretPositions, ICollection<int> mustNotPreplacedCaretPositions)
{
string code = testCode;
const char mustPreplacedChar = '✔';
const char mustNotPreplacedChar = '✘';
int indexOfCaret;
while ((indexOfCaret = code.IndexOfAny(new[] {mustPreplacedChar, mustNotPreplacedChar}, out char which)) >= 0)
{
(which == mustPreplacedChar ? mustPreplacedCaretPositions : mustNotPreplacedCaretPositions).Add(indexOfCaret);
code = code.Remove(indexOfCaret, 1);
}
return code;
}
See More Examples