C# (CSharp) IList Code Examples

C# (CSharp) IList - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для IList, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
        public async Task AssignBatchActionResultsAsync(IODataClient client,
            ODataResponse batchResponse, IList<Func<IODataClient, Task>> actions, IList<int> responseIndexes)
        {
            var exceptions = new List<Exception>();
            for (var actionIndex = 0; actionIndex < actions.Count && !exceptions.Any(); actionIndex++)
            {
                var responseIndex = responseIndexes[actionIndex];
                if (responseIndex >= 0 && responseIndex < batchResponse.Batch.Count)
                {
                    var actionResponse = batchResponse.Batch[responseIndex];
                    if (actionResponse.Exception != null)
                    {
                        exceptions.Add(actionResponse.Exception);
                    }
                    else if (actionResponse.StatusCode >= (int)HttpStatusCode.BadRequest)
                    {
                        exceptions.Add(WebRequestException.CreateFromStatusCode((HttpStatusCode)actionResponse.StatusCode));
                    }
                    else
                    {
                        await actions[actionIndex](new ODataClient(client as ODataClient, actionResponse));
                    }
                }
            }

            if (exceptions.Any())
            {
                throw exceptions.First();
            }
        }
Пример #2
0
        // Varant 2
        private static IList<int> CalculateMembers(int firstMember, int sequenceLength, IList<Func<int, int>> pattern)
        {
            var queue = new Queue<int>(50);
            var result = new List<int>(50);

            // The queue stores members for calculation.
            queue.Enqueue(firstMember);

            // The list stores the result.
            result.Add(firstMember);

            int patternLeadElement = new int();

            for (int counter = 0; counter < sequenceLength; counter += 1)
            {
                var patternIndex = counter % pattern.Count;

                // If a new pattern cycle begun, get new element for calculation.
                if (patternIndex == 0)
                {
                    patternLeadElement = queue.Dequeue();
                }

                // Calculate next member via current pattern method.
                var patternElement = pattern[patternIndex](patternLeadElement);

                queue.Enqueue(patternElement);
                result.Add(patternElement);
            }

            return result.GetRange(0, sequenceLength);
        }
Пример #3
0
        public void Execute(IList<Action> operations, Action<IEnumerable<Action>> remaining)
        {
            for (int i = 0; i < operations.Count; i++)
            {
                if (_stopping)
                    break;

                operations[i]();
            }
        }
Пример #4
0
 public static void DoChaos(Func<bool> doInjectFault, IList<Action> faults)
 {
     if (faults!=null
     && faults.Count>0
     && doInjectFault()
     )
      {
     Trace.WriteLine("CHAOSMONKEY STRIKES AGAIN!!!!");
     faults[_rnd.Next(faults.Count)]();
      }
 }
Пример #5
0
        public virtual void Execute(IList<Action> ops, Action<IEnumerable<Action>> remainingOps)
        {
            for (var i = 0; i < ops.Count; i++)
            {
                if (!AcceptingJobs)
                {
                    remainingOps.NotNull(obj => remainingOps(ops.Skip(i + 1)));
                    break;
                }

                ops[i]();
            }
        }
Пример #6
0
        /// <summary>
        ///   Emits an array.
        /// </summary>
        /// <param name="generator"> The generator. </param>
        /// <param name="arrayType"> Type of the array. </param>
        /// <param name="emitElements"> The emit elements. </param>
        public static void EmitArray(this ILGenerator generator, Type arrayType, IList<Action<ILGenerator>> emitElements)
        {
            var tLocal = generator.DeclareLocal(arrayType.MakeArrayType());
            generator.Emit(OpCodes.Ldc_I4, emitElements.Count);
            generator.Emit(OpCodes.Newarr, arrayType);
            generator.EmitStoreLocation(tLocal.LocalIndex);

            for (var i = 0; i < emitElements.Count; i++) {
                generator.EmitLoadLocation(tLocal.LocalIndex);
                generator.Emit(OpCodes.Ldc_I4, i);
                emitElements[i](generator);
                generator.Emit(OpCodes.Stelem_Ref);
            }
            generator.EmitLoadLocation(tLocal.LocalIndex);
        }
Пример #7
0
 public EnumerationSignature (string serviceName, string enumName, IList<EnumerationValueSignature> values, string documentation)
 {
     Name = enumName;
     FullyQualifiedName = serviceName + "." + Name;
     Values = values;
     Documentation = DocumentationUtils.ResolveCrefs (documentation);
 }
Пример #8
0
 public static void AddRoleClaims(IEnumerable<string> roles, IList<Claim> claims)
 {
     foreach (string role in roles)
     {
         claims.Add(new Claim(RoleClaimType, role, ClaimsIssuer));
     }
 }
Пример #9
0
 public override void AddEffectsInfo(IList<string> list)
 {
     list.Add("25% Group power refresh.");
     list.Add("");
     list.Add("Target: Group");
     list.Add("Casting time: instant");
 }
        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
        {
            var result = context.Result;
            var op1 = context.Operand1;
            var op2 = context.Operand2;
            var constant = Operand.CreateConstant(BuiltInSigType.IntPtr, parameters.Count * 4);

            var eax = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX); // FIXME - need access to virtual register allocator
            var edx = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EDX); // FIXME - need access to virtual register allocator
            var esp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.ESP); // FIXME - need access to virtual register allocator
            var ebp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EBP); // FIXME - need access to virtual register allocator
            context.SetInstruction(X86.Sub, esp, constant);
            context.AppendInstruction(X86.Mov, edx, esp);

            var size = parameters.Count * 4 + 4;
            foreach (var parameter in parameters)
            {
                context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, ebp, new IntPtr(size + 4)));
                size -= 4;
            }
            context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), op1);

            context.AppendInstruction(X86.Mov, eax, op2);
            context.AppendInstruction(X86.Call, null, eax);
            context.AppendInstruction(X86.Add, esp, constant);
            context.AppendInstruction(X86.Mov, result, Operand.CreateCPURegister(result.Type, GeneralPurposeRegister.EAX)); // FIXME - need access to virtual register allocator
        }
Пример #11
0
 public static void GetLocationSelectedListItem(IList<Location> locations, out MultiSelectList allLocation, out List<SelectListItem> selectListItems)
 {
     var multiSelectList = new MultiSelectList(locations, "LocationId", "Province", locations);
     allLocation = multiSelectList;
     selectListItems =
         locations.Select(o => new SelectListItem { Text = o.Province, Value = o.Province }).ToList();
 }
Пример #12
0
		public void Initialise()
		{
			_primitives = new List<Cube>();
			var random = new Random();
			for (int i = 0; i < Constants.CubeCount; i++)
			{
				_primitives.Add(new Cube
					{
						Color = Color.Red,
						Position = new Vector3(random.Next(100) - 50, random.Next(100) - 50, -random.Next(100)),
						Radius = random.Next(100),
						Rotation = Vector3.Zero
					});
			}
            //How to create a kernel and a channel?
//			_kernel = 
//		    _channel = 

			

			_colour = Color.Beige;
			
			_kernel.Factory.NewCoroutine(ChangePosition);
			_kernel.Factory.NewCoroutine(ChangeColour);
		    
		}
Пример #13
0
        public void should_parse_objects_symbols_and_properties_when_parsing_more_complex_xml_content()
        {
            Lexemes = Parser.Parse(ComplexXml);

            Lexemes.Count.ShouldBe(136);
            Lexemes.Count(lx => lx.Type == LexemType.Comment).ShouldBe(6);
        }
        public DefaultRequestDispatcherFixture()
        {
            this.responseProcessors = new List<IResponseProcessor>();
            this.routeResolver = A.Fake<IRouteResolver>();
            this.routeInvoker = A.Fake<IRouteInvoker>();
            this.negotiator = A.Fake<IResponseNegotiator>();

            A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._))
                .ReturnsLazily(async arg =>
                {
                    var routeResult = ((Route)arg.Arguments[0]).Invoke((DynamicDictionary)arg.Arguments[2], new CancellationToken()).ConfigureAwait(false);
                    var x = await routeResult;

                    return (Response)x;
                });

            this.requestDispatcher =
                new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker, this.negotiator);

            var resolvedRoute = new ResolveResult
            {
                Route = new FakeRoute(),
                Parameters = DynamicDictionary.Empty,
                Before = null,
                After = null,
                OnError = null
            };

            A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute);
        }
Пример #15
0
 private ParametriAggiuntiviCompilazioneLettera(TipoModelloLetteraEnum tipoLettera = TipoModelloLetteraEnum.Messaggistica, string bodyFormat = "PLAIN", List<TipoMessaggio> tipiMessaggioConsentiti = null, TipoMessaggio tipoMessaggioPredefinito = TipoMessaggio.Manuale)
 {
     TipoLettera = tipoLettera;
     BodyFormat = bodyFormat;
     TipiMessaggioConsentiti = tipiMessaggioConsentiti;
     TipoMessaggioPredefinito = tipoMessaggioPredefinito;
 }
Пример #16
0
 /// <summary>
 /// Recursive menu builder
 /// </summary>
 /// <param name="flatList">Original flat menu items list</param>
 /// <param name="parentId">Parent node ID</param>
 /// <returns>Hierarchical list</returns>
 private IList<SiteMapItem> BuildTree(IList<SiteMapItem> flatList, int parentId)
 {
     var list = new List<SiteMapItem>();
     EnumerableExtensions.ForEach(flatList.Where(x => x.ParentId == parentId), list.Add);
     list.ForEach(x => x.Children = BuildTree(flatList, x.Id));
     return list;
 }
Пример #17
0
        public ICLS_Expression Compiler(IList<Token> tlist, ICLS_Environment content)
        {
            ICLS_Expression value;

            int expbegin = 0;
            int expend = FindCodeBlock(tlist, expbegin);
            if (expend != tlist.Count - 1)
            {
                LogError(tlist, "CodeBlock 识别问题,异常结尾", expbegin, expend);
                return null;
            }
            bool succ = Compiler_Expression_Block(tlist, content, expbegin, expend, out value);
            if (succ)
            {
                if (value == null)
                {
                    logger.Log_Warn("编译为null:");
                }
                return value;

            }
            else
            {
                LogError(tlist, "编译失败:", expbegin, expend);
                return null;
            }



        }
        public void SetCurrent(UiEncodingWindowSource source, IList<int> mainIndices, IList<int> additionalIndices)
        {
            CurrentSource = source;
            CurrentMainIndices = mainIndices;
            CurrentAdditionalIndices = additionalIndices;

            for (int i = mainIndices.Count; i < _mainControls.Count; i++)
                _mainControls[i].Visibility = Visibility.Collapsed;
            for (int i = additionalIndices.Count; i < _additionalControls.Count; i++)
                _additionalControls[i].Visibility = Visibility.Collapsed;

            if (CurrentSource == null)
                return;

            for (int i = 0; i < mainIndices.Count; i++)
            {
                _mainControls[i].Load(source, mainIndices[i]);
                _mainControls[i].Visibility = Visibility.Visible;
            }

            for (int i = 0; i < additionalIndices.Count; i++)
            {
                _additionalControls[i].Load(source, additionalIndices[i]);
                _additionalControls[i].Visibility = Visibility.Visible;
            }

            _drawEvent.NullSafeSet();
        }
Пример #19
0
	public SmugglerApi(SmugglerOptions smugglerOptions, IAsyncDatabaseCommands commands, Action<string> output)
		: base(smugglerOptions)
	{
		this.commands = commands;
		this.output = output;
		batch = new List<RavenJObject>();
	}
 public static void Require(IList<string> errors, string fieldValue, string error)
 {
     if (String.IsNullOrEmpty(fieldValue))
     {
         errors.Add(error);
     }
 }
 private double GetHeightFromChildren(IList<ICanvasItem> children)
 {
     children.SwapCoordinates();
     var maxBottom = GetMaxRightFromChildren(children);
     children.SwapCoordinates();
     return maxBottom - Top;
 }
Пример #22
0
        public override void Draw(
			IList<Point> points,
			double thickness,
			int miterLimit,
			ILogicalToScreenMapper logicalToScreenMapper)
        {
            // First define the geometric shape
            var streamGeometry = new StreamGeometry();
            using (var gc = streamGeometry.Open())
            {
                gc.BeginFigure(points[0], _fillAndClose, _fillAndClose);
                points.RemoveAt(0);

                gc.PolyLineTo(points, true, true);
            }

            using (var dc = RenderOpen())
                dc.DrawGeometry(
                    _fillAndClose ? Brushes.White : null,
                    new Pen(
                        Brushes.White,
                        thickness == 1 ? 0.25 : thickness)
                        {
                            MiterLimit = miterLimit
                        },
                    streamGeometry);
        }
Пример #23
0
        public RecordsetGroup(IBinaryDataListEntry sourceEntry, IList<IDev2Definition> definitions, Func<IDev2Definition, string> inputExpressionExtractor, Func<IDev2Definition, string> outputExpressionExtractor)
        {
            if(sourceEntry == null)
            {
                throw new ArgumentNullException("sourceEntry");
            }

            if(definitions == null)
            {
                throw new ArgumentNullException("definitions");
            }
            if(inputExpressionExtractor == null)
            {
                throw new ArgumentNullException("inputExpressionExtractor");
            }
            if(outputExpressionExtractor == null)
            {
                throw new ArgumentNullException("outputExpressionExtractor");
            }

            SourceEntry = sourceEntry;
            Definitions = definitions;
            InputExpressionExtractor = inputExpressionExtractor;
            OutputExpressionExtractor = outputExpressionExtractor;
        }
Пример #24
0
 public static IList<QueryReference> DiscoverQueryReferences(this SqlExpression expression, ref int level, IList<QueryReference> list)
 {
     var visitor = new QueryReferencesVisitor(list, level);
     visitor.Visit(expression);
     level = visitor.Level;
     return visitor.References;
 }
Пример #25
0
        /// <summary>
        /// Gets a list of variable binds.
        /// </summary>
        /// <param name="version">Protocol version.</param>
        /// <param name="endpoint">Endpoint.</param>
        /// <param name="community">Community name.</param>
        /// <param name="variables">Variable binds.</param>
        /// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param>
        /// <returns></returns>
        public static IList<Variable> Get(VersionCode version, IPEndPoint endpoint, OctetString community, IList<Variable> variables, int timeout)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            if (community == null)
            {
                throw new ArgumentNullException("community");
            }

            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            if (version == VersionCode.V3)
            {
                throw new NotSupportedException("SNMP v3 is not supported");
            }

            var message = new GetRequestMessage(RequestCounter.NextId, version, community, variables);
            var response = message.GetResponse(timeout, endpoint);
            var pdu = response.Pdu();
            if (pdu.ErrorStatus.ToInt32() != 0)
            {
                throw ErrorException.Create(
                    "error in response",
                    endpoint.Address,
                    response);
            }

            return pdu.Variables;
        }
Пример #26
0
        private void TranslateInput(string input)
        {
            var indexOfFirstSeparator = input.IndexOf(SplitCommandSymbol);

            this.Name = input.Substring(0, indexOfFirstSeparator);
            this.Parameters = input.Substring(indexOfFirstSeparator + 1).Split(new[] { SplitCommandSymbol }, StringSplitOptions.RemoveEmptyEntries);
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            int position = session.TextView.Caret.Position.BufferPosition.Position;
            var line = _buffer.CurrentSnapshot.Lines.SingleOrDefault(l => l.Start <= position && l.End >= position);
            if (line == null) return;

            int linePos = position - line.Start.Position;

            var info = NodeModuleCompletionUtils.FindCompletionInfo(line.GetText(), linePos);
            if (info == null) return;

            var callingFilename = _buffer.GetFileName();
            var baseFolder = Path.GetDirectoryName(callingFilename);

            IEnumerable<Completion> results;
            if (String.IsNullOrWhiteSpace(info.Item1))
                results = GetRootCompletions(baseFolder);
            else
                results = GetRelativeCompletions(NodeModuleService.ResolvePath(baseFolder, info.Item1));

            var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(info.Item2.Start + line.Start, info.Item2.Length, SpanTrackingMode.EdgeInclusive);
            completionSets.Add(new CompletionSet(
                "Node.js Modules",
                "Node.js Modules",
                trackingSpan,
                results,
                null
            ));
        }
Пример #28
0
 private static void CheckIfReturnsSpecifiedType(ExpressionNode expression, IList<Error> errors, TigerType type)
 {
     if (!(expression.ReturnType == type)) {
         errors.Add(new UnexpectedTypeError(expression.Line, expression.Column, expression.ReturnType,
                                            IntegerType.Create()));
     }
 }
        //public IList<MergeField> AnnexMergeFields { get; private set; }

        public CustomsOfficeBlock(IList<MergeField> mergeFields, TransportRoute transportRoute)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new CustomsOfficeViewModel(transportRoute);

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
Пример #30
0
        public void GivenANewHostedGameWithPlayers(int playerCount)
        {
            var gameBinding = Binding<GameStateBindings>();
            gameBinding.GivenANewGameWithPlayers(playerCount);

            _gameHost = new LockingGameHost(gameBinding.Game);           

            _clients = new List<GameClient>();
            _notifications = new Dictionary<GameClient, int>();

            foreach(var player in gameBinding.Game.Players)
            {
                var client = new GameClient(player.Id, player.Name);
                _gameHost.RegisterGameClient(client, player);
                _clients.Add(client);
                _notifications[client] = 0;
                client.GameStateUpdates.Subscribe( _ =>
                                                       {                                                           
                                                           _notifications[client] += 1;
                                                       });
            }

            

        }