当前位置: 首页>>代码示例>>C#>>正文


C# ICollection.Add方法代码示例

本文整理汇总了C#中ICollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.Add方法的具体用法?C# ICollection.Add怎么用?C# ICollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICollection的用法示例。


在下文中一共展示了ICollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProduceItemInField

        //Generate new item on the field.
        public static void ProduceItemInField(FrameAnimation enemyAnimation, Enemy enemy, ICollection<IItem> visibleItems)
        {
            Point2D itemPosition = new Point2D(0, 0);

            if (enemy is Zombie)
            {
                if (enemyAnimation.SpriteEffect == SpriteEffects.None)
                {
                    itemPosition = new Point2D(enemyAnimation.Position.X, enemyAnimation.Position.Y + MovingDistanceStomper);
                }
                else
                {
                    itemPosition = new Point2D(enemyAnimation.Position.X + 100, enemyAnimation.Position.Y + MovingDistanceStomper);
                }

                visibleItems.Add(new Stomper("Stomper", itemPosition, OrusTheGame.Instance.Content));

            }
            else if (enemy is Skeleton)
            {

                if (enemyAnimation.SpriteEffect == SpriteEffects.None)
                {
                    itemPosition = new Point2D(enemyAnimation.Position.X, enemyAnimation.Position.Y + MovingDistanceArmour);
                }
                else
                {
                    itemPosition = new Point2D(enemyAnimation.Position.X + 100, enemyAnimation.Position.Y + MovingDistanceArmour);
                }

                visibleItems.Add(new GiantArmour("GiantArmour", itemPosition, OrusTheGame.Instance.Content));
            }
        }
开发者ID:EvgeniYorgakiev,项目名称:Orus,代码行数:34,代码来源:ItemFactory.cs

示例2: RegisterCommands

		void RegisterCommands(ICollection<CommandBinding> commandBindings)
		{
			commandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind));
			commandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext));
			commandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious));
			commandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, ExecuteCloseSearchPanel));
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:7,代码来源:SearchCommands.cs

示例3: CollectValidationErrors

 public override void CollectValidationErrors(ICollection<string> errors)
 {
     if (String.IsNullOrEmpty(TableName))
         errors.Add(ErrorMessages.TableNameCannotBeNullOrEmpty);
     if (String.IsNullOrEmpty(DestinationSchemaName))
         errors.Add(ErrorMessages.DestinationSchemaCannotBeNull);
 }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:7,代码来源:AlterSchemaExpression.cs

示例4: RecursiveFindAndAddNodes

        private void RecursiveFindAndAddNodes(ICollection<Node> foundNodes, ArrayList nodesToSearch)
        {
            foreach (Node node in nodesToSearch)
            {
                if (!IsNodeSuitableForIndexing(node))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(node.Id))
                {
                    foundNodes.Add(node);
                }

                if( node.EnumData != null && node.EnumData.Count > 0 )
                {
                    foreach(string enumVal in node.EnumData)
                    {
                        Node en = LibrarySearchMgr.StaticCreateNodeForEnumValue(node, enumVal);
                        foundNodes.Add(en);
                    }
                }

                if (node.HasChildren)
                {
                    RecursiveFindAndAddNodes(foundNodes, node.Children);
                }
            }
        }
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:29,代码来源:DeepTaxonomyNodeFinder.cs

示例5: CreateObjects

 private static void CreateObjects(ICollection<ExampleObject> list, int n = 50)
 {
     for (int i = 0; i < n; i++)
     {
         list.Add(
             new ExampleObject
             {
                 Boolean = true,
                 DateTime = DateTime.Now,
                 Color = Colors.Blue,
                 Number = Math.PI,
                 Fruit = Fruit.Apple,
                 Integer = 7,
                 Selector = null,
                 String = "Hello"
             });
         list.Add(
             new ExampleObject
             {
                 Boolean = false,
                 DateTime = DateTime.Now.AddDays(-1),
                 Color = Colors.Gold,
                 Number = Math.E,
                 Fruit = Fruit.Pear,
                 Integer = -1,
                 Selector = null,
                 String = "World"
             });
     }
 }
开发者ID:Mitch-Connor,项目名称:PropertyTools,代码行数:30,代码来源:ExampleViewModel.cs

示例6: HandleCore

 protected override bool HandleCore(TokenParser context, ICollection<Token> tokens, char ch)
 {
     if (ch == '>')
     {
         Token token = context.SwitchState(TokenType.Text, new TextHandler());
         tokens.Add(token);
         if (token.Type == TokenType.OpenTag && (token.Value == "script" || token.Value == "style"))
         {
             tokens.Add(context.SwitchState(TokenType.Text, new CDataHandler(string.Format("</{0}", token.Value))));
         }
         return true;
     }
     if (ch == '/' || Char.IsWhiteSpace(ch))
     {
         var handler = new AttibuteNameHandler();
         Token token = context.SwitchState(TokenType.AttributeName, handler);
         if (token.Type == TokenType.OpenTag && (token.Value == "script" || token.Value == "style"))
         {
             handler.ReplaceNextTagOrTextTokenWithCData = string.Format("</{0}", token.Value);
         }
         tokens.Add(token);
         return true;
     }
     return false;
 }
开发者ID:erguen,项目名称:HtmlParser,代码行数:25,代码来源:TagHandler.cs

示例7: Initialize

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            _spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            _myBall = new Ball();
            _myBall.VelocityFromAngle(180.0f * (float)Math.PI / 180.0f, 800);
            _myBall.Circle.Position.X = 180;
            _myBall.Circle.Position.Y = 100 + 44;

            _levelBricks = new List<AABB>();

            _levelBricks.Add(new AABB(0, 0, 1, Game.Window.ClientBounds.Height));
            _levelBricks.Add(new AABB(0, Game.Window.ClientBounds.Height, Game.Window.ClientBounds.Width, 1));
            _levelBricks.Add(new AABB(Game.Window.ClientBounds.Width, 0, 1, Game.Window.ClientBounds.Height));
            _levelBricks.Add(new AABB(0, 0, Game.Window.ClientBounds.Width, 1));

            //_levelBricks.Add(new AABB(200, 100, 20, 65));
            //_levelBricks.Add(new AABB(200, 220, 20, 20));

            //_levelBricks.Add(new AABB(300, 300, 20, 20));
            //_levelBricks.Add(new AABB(20, 20, 20, 20));

            //Random r = new Random();

            //for (int i = 0; i < 40; ++i)
            //{
            //    _levelBricks.Add(new AABB(r.Next(0, Game.Window.ClientBounds.Width), r.Next(0, Game.Window.ClientBounds.Height), r.Next(20, 30), r.Next(20, 30)));
            //}

            _prevKeyState = Keyboard.GetState();

            base.Initialize();
        }
开发者ID:axelo,项目名称:Noid,代码行数:38,代码来源:BallComponent.cs

示例8: PurchaseService

        public PurchaseService(int dollarCoins, int quarterCoins, int dimeCoins, int nickleCoins, int pennyCoins)
        {
            _changeCoins = new List<Coin>();

            for (int i = 0; i < dollarCoins; i++)
            {
                _changeCoins.Add(new Coin() {ShortName = "o", Title = "Dollar", Value = 1});
            }
            for (int i = 0; i < quarterCoins; i++)
            {
                _changeCoins.Add(new Coin() { ShortName = "q", Title = "Quarter", Value = .25m});
            }
            for (int i = 0; i < dimeCoins; i++)
            {
                _changeCoins.Add(new Coin() { ShortName = "d", Title = "Dime", Value = .1m });
            }
            for (int i = 0; i < nickleCoins; i++)
            {
                _changeCoins.Add(new Coin() { ShortName = "n", Title = "Nickle", Value = .05m });
            }
            for (int i = 0; i < pennyCoins; i++)
            {
                _changeCoins.Add(new Coin() { ShortName = "p", Title = "Penny", Value = .01m });
            }
        }
开发者ID:andrewleaf,项目名称:CodeKata,代码行数:25,代码来源:PurchaseService.cs

示例9: BuildElement

        private void BuildElement(ElementBlock elementBlock, ICollection<string> path)
        {
            if (!elementBlock.IsRoot())
            {
                path.Add(elementBlock.Selector.ToCss());
                path.Add(elementBlock.Name);

                //Only add an element to the document when we have reached the end of the path
                if (elementBlock.Properties.Count != 0)
                {
                    var cssProperties = new List<CssProperty>();

                    foreach (var property in elementBlock.Properties)
                        cssProperties.Add(new CssProperty(property.Key, property.Evaluate().ToCss()));

                    //Get path content i.e. "p > a:Hover"
                    var pathContent = path.Where(p => !string.IsNullOrEmpty(p)).JoinStrings(string.Empty);
                    pathContent = pathContent.StartsWith(" ") ? pathContent.Substring(1) : pathContent;
                    document.Elements.Add(new CssElement(pathContent, cssProperties));
                }
            }
            if (elementBlock.Inserts.Count == 0) return;
            foreach (var insert in elementBlock.Inserts)
                document.Elements.Add(new CssElement { InsertContent = insert.ToString() });
        }
开发者ID:JasonCline,项目名称:dotless,代码行数:25,代码来源:LessToCssDomConverter.cs

示例10: AddUvs

 private static void AddUvs(int tileRow, float tileSizeY, float tileSizeX, ICollection<Vector2> uvs, int tileColumn)
 {
     uvs.Add(new Vector2(tileColumn * tileSizeX, tileRow * tileSizeY));
     uvs.Add(new Vector2((tileColumn + 1) * tileSizeX, tileRow * tileSizeY));
     uvs.Add(new Vector2((tileColumn + 1) * tileSizeX, (tileRow + 1) * tileSizeY));
     uvs.Add(new Vector2(tileColumn * tileSizeX, (tileRow + 1) * tileSizeY));
 }
开发者ID:Togene,项目名称:BeCalm,代码行数:7,代码来源:CreateMesh.cs

示例11: Flatten

        /// <summary>
        /// Flattens the specified curve. See <see cref="ICurve{TParam, TPoint}.Flatten"/>.
        /// </summary>
        /// <remarks>
        /// This method cannot be used for curves that contain gaps!
        /// </remarks>
        internal static void Flatten(ICurve<float, Vector3F> curve, ICollection<Vector3F> points, int maxNumberOfIterations, float tolerance)
        {
            if (tolerance <= 0)
            throw new ArgumentOutOfRangeException("tolerance", "The tolerance must be greater than zero.");

              float totalLength = curve.GetLength(0, 1, maxNumberOfIterations, tolerance);

              // No line segments if the curve has zero length.
              if (totalLength == 0)
            return;

              // A single line segment if the curve's length is less than the tolerance.
              if (totalLength < tolerance)
              {
            points.Add(curve.GetPoint(0));
            points.Add(curve.GetPoint(1));
            return;
              }

              var list = ResourcePools<Vector3F>.Lists.Obtain();

              Flatten(curve, list, 0, 1, curve.GetPoint(0), curve.GetPoint(1), 0, totalLength, 1, maxNumberOfIterations, tolerance);

              foreach (var point in list)
            points.Add(point);

              ResourcePools<Vector3F>.Lists.Recycle(list);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:34,代码来源:CurveHelper_Flatten.cs

示例12: Circle

 private static void Circle(ICollection<ExtendedOpenGlPoint> list, double r, double y, Point center)
 {
     var n = (int)Math.Round(r) * 20;
     var start = new Point();
     for (var i = 0; i < n; i++)
     {
         var angle = 2 * Math.PI * i / n;
         if (i == 0)
         {
             start.X = Math.Round(r * Math.Sin(angle), 5);
             start.Y = Math.Round(r * Math.Cos(angle), 5);
         }
         list.Add(new ExtendedOpenGlPoint(
                 r * Math.Sin(angle) + center.X,
                 y,
                 r * Math.Cos(angle) + center.Y,
                 0,
                 new float[] { 0, 0, 0 }));
     }
     list.Add(new ExtendedOpenGlPoint(
             start.X + center.X,
             y,
             start.Y + center.Y,
             0,
             new float[] { 0, 0, 0 }));
 }
开发者ID:KyMaP13,项目名称:sharpcam,代码行数:26,代码来源:GCodeGenerator.cs

示例13: GetPayloads

 private static IEnumerable<PayloadDTO> GetPayloads(IEnumerable<string> types, ICollection<PayloadDTO> list)
 {
     foreach (var item in types)
     {
         switch (item)
         {
             case ("1"):
                 list.Add(new PhotoDTO() { Id = 1 });
                 break;
             case ("2"):
                 list.Add(new TVDTO() { Id = 2 });
                 break;
             case ("3"):
                 list.Add(new IRDTO() { Id = 3 });
                 break;
             case ("4"):
                 list.Add(new FrontalDTO() { Id = 4 });
                 break;
             case ("5"):
                 list.Add(new MultispectralDTO() { Id = 5 });
                 break;
             case ("10"):
                 list.Add(new OtusDTO() { Id = 10 });
                 break;
             default:
                 throw new ArgumentOutOfRangeException("Exception in  GetPayload method");
         }
     }
     return list;
 }
开发者ID:sweexxik,项目名称:Uav-Site,代码行数:30,代码来源:UavModelBinder.cs

示例14: ModifySetForTest

 private void ModifySetForTest(ICollection<int> set)
 {
     set.Remove(1);
     set.Remove(2);
     set.Add(4);
     set.Add(5);
 }
开发者ID:SaladLab,项目名称:TrackableData,代码行数:7,代码来源:StorageSetValueTestKit.cs

示例15: ParseDealPage

        public static void ParseDealPage(HtmlDocument htmlDoc, ICollection<SteamSpecialItemViewModel> retList)
        {
            if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
            {
                return;
            }
            if (htmlDoc.DocumentNode != null)
            {
                var searchResults = htmlDoc.DocumentNode.SelectSingleNode("//div[@id='search_results']");

                if (searchResults != null)
                {
                    var even = searchResults.SelectNodes("//a[@class='search_result_row even']");
                    var odd = searchResults.SelectNodes("//a[@class='search_result_row odd']");

                    if (even != null && odd != null)
                    {
                        var max = Math.Max(even.Count, odd.Count);
                        for (var i = 0; i < max; ++i)
                        {
                            if (i < even.Count)
                            {
                                retList.Add(ParseNode(even[i]));
                            }
                            if (i < odd.Count)
                            {
                                retList.Add(ParseNode(odd[i]));
                            }
                        }
                    }
                }
            }
        }
开发者ID:sinhpham,项目名称:steamspecials,代码行数:33,代码来源:SSParser.cs


注:本文中的ICollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。