Children.Add C# (CSharp) Метод

Add() публичный Метод

public Add ( string name ) : void
name string
Результат void
        public void Add(string name)
        {
             Child child = this[name];
             if(null == child)
             {
                 child = new Child(new XElement("Name"));
                 child.Name = name;
                 self.Add(child.self);
             }
             else
                 throw new ArgumentException("Child with name: "+ name +" already exists!");
        }
    }

Usage Example

Пример #1
0
        public void BuildTiles(IEnumerable <object> tiles)
        {
            try
            {
                if (tiles == null || tiles.Count() == 0)
                {
                    Children?.Clear();
                }

                // Wipe out the previous row definitions if they're there.
                RowDefinitions?.Clear();

                var enumerable   = tiles as IList ?? tiles.ToList();
                var numberOfRows = Math.Ceiling(enumerable.Count / (float)MaxColumns);

                for (var i = 0; i < numberOfRows; i++)
                {
                    RowDefinitions?.Add(new RowDefinition {
                        Height = TileHeight
                    });
                }

                for (var index = 0; index < enumerable.Count; index++)
                {
                    var column = index % MaxColumns;
                    var row    = (int)Math.Floor(index / (float)MaxColumns);

                    var tile = BuildTile(enumerable[index]);

                    Children?.Add(tile, column, row);
                }
            }
            catch { // can throw exceptions if binding upon disposal
            }
        }
All Usage Examples Of Children::Add