Beispiel #1
0
        /// <summary>
        /// Getting a MD hash sequence for datastructure
        /// </summary>
        /// <param name="dta_struct">Data Structure</param>
        /// <returns></returns>
        public static string MD5Hash( IStructure dta_struct )
        {
            var str_hash = new StringBuilder( 32 );
            var str_elements = new StringBuilder( 32 );
            byte[] data_bytes = null;
            if (dta_struct != null) {
                if ( dta_struct is DataContainer ) {
                    foreach ( var clmn in  ((DataContainer)dta_struct).Columns ){
                        str_elements.Append( clmn.Name );
                        str_elements.Append( clmn.Type.ToString());
                    }
                    data_bytes = Encoding.UTF8.GetBytes(((DataContainer)dta_struct).Name +
                                                        str_elements.ToString());
                } else {
                    if ( dta_struct is Record ) {
                        // Let's assume, that Record Id is unique
                        str_elements.Append(((Record)dta_struct).Id.ToString());
                        data_bytes = Encoding.UTF8.GetBytes(((Record)dta_struct).Id.ToString() +
                                                            str_elements.ToString());
                    }
                }

                foreach (byte b in new MD5CryptoServiceProvider().ComputeHash(data_bytes))
                {
                    str_hash.Append(b.ToString("X2"));
                }
            } else
                throw new IOException( "Error in generating hash code: data structure is null" );
            return str_hash.ToString();
        }
        public virtual void Insert(IStructureSchema structureSchema, IStructure[] structures)
        {
            var groupedIndexInsertActions = new IndexInsertAction[0];

            Task task = null;
            try
            {
                task = Task.Factory.StartNew(
                    () => groupedIndexInsertActions = CreateGroupedIndexInsertActions(structureSchema, structures));

                InsertStructures(structureSchema, structures);
                InsertUniques(structureSchema, structures);

                Task.WaitAll(task);
            }
            finally
            {
                if (task != null && task.Status == TaskStatus.RanToCompletion)
                    task.Dispose();
            }

            if (!groupedIndexInsertActions.Any())
                return;

            InsertIndexes(groupedIndexInsertActions);
        }
        public virtual void InsertIndexesOnly(IStructureSchema structureSchema, IStructure[] structures)
        {
            var groupedIndexInsertActions = CreateGroupedIndexInsertActions(structureSchema, structures);
            if (!groupedIndexInsertActions.Any())
                return;

            InsertIndexes(groupedIndexInsertActions);
        }
Beispiel #4
0
 public new void Add(IStructure dta_struct)
 {
     string new_index_hash = dta_struct.GetIndex().DwarfHashCode;
     if (dta_struct is Record)
     {
         items_dict.TryAdd(new_index_hash, dta_struct);
         Modified = true;
     }
 }
 void IField.SetFieldData(byte[] field_data, IStructure caller)
 {
     offset0 = BitConverter.ToInt32(field_data, 0);
     offset1 = BitConverter.ToInt32(field_data, 4);
     offset2 = BitConverter.ToInt32(field_data, 8);
                                                         // <- the other 3 LODs which are never used.
     length0 = BitConverter.ToInt32(field_data, 24);
     length1 = BitConverter.ToInt32(field_data, 28);
     length2 = BitConverter.ToInt32(field_data, 32);
 }
        protected virtual void InsertStructures(IStructureSchema structureSchema, IStructure[] structures)
        {
            if (!structures.Any())
                return;

            if (structures.Length == 1)
                MainDbClient.SingleInsertStructure(structures[0], structureSchema);
            else
                MainDbClient.BulkInsertStructures(structureSchema, structures);
        }
        public virtual void Replace(IStructureSchema structureSchema, IStructure structure)
        {
            var structures = new[] { structure };
            MainDbClient.SingleUpdateOfStructure(structure, structureSchema);
            InsertUniques(structureSchema, structures);

            var groupedIndexInsertActions = CreateGroupedIndexInsertActions(structureSchema, new[] { structure });
            if (!groupedIndexInsertActions.Any())
                return;

            InsertIndexes(groupedIndexInsertActions);
        }
Beispiel #8
0
        public ConfigurationController(IDocumentRepository documentRepository,
		                                IStructureRepository structureRepository)
            : base(true)
        {
            _documentRepository = documentRepository;
            _structureRepository = structureRepository;

            _document = new Document(_documentRepository);
            _structure = new Structure(_structureRepository);

            _user = new User();
        }
        /// <summary>
        /// Replaces one ConstructingBuilding with an IStructure.
        /// </summary>
        /// <param name="sender">ConstructingBuilding to be replaced</param>
        /// <param name="eventArgs">EventArgs containing new structure's definition</param>
        public void ReplaceBuilding(object sender, EventArgsWithPayload <IStructureDef> eventArgs)
        {
            if (!(sender is ConstructingBuildingController structure))
            {
                return;
            }

            //    Remove old structure
            DespawnStructure(structure);

            //    Add new structure
            BuildingFactory factory = new BuildingFactory(structure.Faction, Game);

            IStructure <IStructureDef> building = factory.CreateNewBuilding(structure.Def.CompletedBuildingDef);

            SpawnStructure(structure.StartCoords, building);
        }
        public IStructure[] CreateStructures <T>(T[] items) where T : class
        {
            var schema = GetSchema(typeof(T));

            var structures = new IStructure[items.Length];

            for (var i = 0; i < structures.Length; i++)
            {
                var itm = items[i];

                structures[i] = new Structure(
                    schema.Name,
                    CreateIndexes(schema, itm));
            }

            return(structures);
        }
Beispiel #11
0
        public static ZilObject PUT(Context ctx, [NotNull] IStructure st, int idx, ZilObject newValue)
        {
            try
            {
                st[idx - 1] = newValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InterpreterError(InterpreterMessages._0_Writing_Past_End_Of_Structure, "PUT");
            }
            catch (NotSupportedException)
            {
                throw new InterpreterError(InterpreterMessages._0_Element_1_Is_Read_Only, "PUT", idx);
            }

            return((ZilObject)st);
        }
Beispiel #12
0
 private void currentStructure_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (currentStructure.GetType() == typeof(Wall) && PlaceWall(currentStructure as Wall) || currentStructure is Turret && game.Grid.SnapObject(currentStructure))
     {
         currentStructure.Place();
         currentStructure.Model.MouseDown -= currentStructure_MouseDown;
         placedStructures.Push(currentStructure);
         if (game.PlayerCash >= currentStructure.Cost)
         {
             currentStructure = PurchaseStructure(currentStructure.GetType());
         }
         else
         {
             currentStructure = null;
         }
     }
 }
        public void AddStructure(IStructure <IStructureDef> building)
        {
            foreach (Coords coords in building.Def.BuildingShape)
            {
                Coords actual = coords + building.StartCoords;

                WorldCellController cell = GetCellFromCoords(actual);

                // add building to the cells its on
                cell.worldCellModel.BuildingOnTop = building;
                // add cells to the building
                building.OccupiedCells.Add(cell.worldCellModel);
            }

            // add building to buildinglist
            WorldModel.Structures.Add(building);
        }
Beispiel #14
0
        public void SenseOfUrgency_WhenCityHasNoSenseOfUrgencyTechnologies_HealsHurtStructuresThatArentInBattle(
            ICity city,
            IStructure inBattleStructure,
            IStructure fullyHealedStructure,
            IStructure hurtStructure,
            BattleProcedure battleProcedure)
        {
            inBattleStructure.State = GameObjectStateFactory.BattleState(0);
            inBattleStructure.Stats.Hp.Returns(50m);
            inBattleStructure.Stats.Base.Battle.MaxHp.Returns(100m);

            fullyHealedStructure.State = GameObjectStateFactory.NormalState();
            fullyHealedStructure.Stats.Hp.Returns(75m);
            fullyHealedStructure.Stats.Base.Battle.MaxHp.Returns(75m);

            hurtStructure.State = GameObjectStateFactory.NormalState();
            hurtStructure.Stats.Hp.Returns(100m);
            hurtStructure.Stats.Base.Battle.MaxHp.Returns(200m);

            city.GetEnumerator().Returns(x =>
                                         new List <IStructure> {
                inBattleStructure, fullyHealedStructure, hurtStructure
            }.GetEnumerator());
            city.Technologies.GetEffects(EffectCode.SenseOfUrgency).Returns(new List <Effect>
            {
                new Effect {
                    Id = EffectCode.SenseOfUrgency, Value = new object[] { 50 }
                }
            });

            battleProcedure.SenseOfUrgency(city, 50);

            inBattleStructure.Stats.Hp.Should().Be(50m);
            hurtStructure.Stats.Hp.Should().Be(125m);
            fullyHealedStructure.Stats.Hp.Should().Be(75m);

            hurtStructure.Received(1).BeginUpdate();
            hurtStructure.Received(1).EndUpdate();

            fullyHealedStructure.Received(0).BeginUpdate();
            fullyHealedStructure.Received(0).EndUpdate();

            inBattleStructure.Received(0).BeginUpdate();
            inBattleStructure.Received(0).EndUpdate();
        }
Beispiel #15
0
        /// <summary>
        ///     Creates a city under the specified player with initial troop and main building
        /// </summary>
        public virtual void CreateCity(ICityFactory cityFactory, IPlayer player, string cityName, byte level, Position cityPosition, IBarbarianTribeManager barbarianTribeManager, out ICity city)
        {
            city = cityFactory.CreateCity(world.Cities.GetNextCityId(),
                                          player,
                                          cityName,
                                          cityPosition,
                                          formula.GetInitialCityResources(),
                                          formula.GetInitialCityRadius(),
                                          formula.GetInitialAp(),
                                          Theme.DEFAULT_THEME_ID,
                                          Theme.DEFAULT_THEME_ID,
                                          Theme.DEFAULT_THEME_ID,
                                          Theme.DEFAULT_THEME_ID);

            var        mainBuildingPosition = cityPosition.Left();
            IStructure mainBuilding         = city.CreateStructure(2000, level, mainBuildingPosition.X, mainBuildingPosition.Y);

            player.Add(city);

            world.Cities.Add(city);

            city.BeginUpdate();

            mainBuilding.BeginUpdate();
            world.Regions.Add(mainBuilding);
            mainBuilding.EndUpdate();

            var defaultTroop = city.CreateTroopStub();

            defaultTroop.BeginUpdate();
            defaultTroop.AddFormation(FormationType.Normal);
            defaultTroop.AddFormation(FormationType.Garrison);
            defaultTroop.AddFormation(FormationType.InBattle);
            defaultTroop.EndUpdate();

            RecalculateCityResourceRates(city);
            SetResourceCap(city);

            city.EndUpdate();

            if (player.GetCityCount() == 1)
            {
                barbarianTribeManager.CreateBarbarianTribeNear(1, 10, city.PrimaryPosition.X, city.PrimaryPosition.Y, 10);
            }
        }
Beispiel #16
0
        public override IEnumerable <Selection> Select(IStructure structure)
        {
            List <Selection> results = new List <Selection>();

            for (int chainIndex = 0; chainIndex < structure.Count; chainIndex++)
            {
                if (chainIndex == ChainIndex)
                {
                    continue;
                }

                IChain         chain           = structure[chainIndex];
                List <SSBlock> chainSelections = SecondaryStructure.GetPhiPsiSSBlocks(chain, MinLength);

                if (IncludeAdjacentLoops)
                {
                    // Extend the SSBlock ranges to include everything up to the neighboring blocks
                    List <SSBlock> extendedChainSelections = new List <SSBlock>();
                    for (int selectionIndex = 0; selectionIndex < chainSelections.Count; selectionIndex++)
                    {
                        int start = selectionIndex == 0 ? 0 : chainSelections[selectionIndex - 1].End + 1;
                        int end   = selectionIndex == chainSelections.Count - 1 ? chain.Count - 1 : chainSelections[selectionIndex + 1].Start - 1;
                        extendedChainSelections.Add(new SSBlock(chainSelections[selectionIndex].SS, start, end));
                    }
                    chainSelections = extendedChainSelections;
                }

                if (SkipCountC != null && SkipCountC > 0)
                {
                    int firstSkipIndex = Math.Max(0, chainSelections.Count - (int)SkipCountC);
                    chainSelections.RemoveRange(firstSkipIndex, chainSelections.Count - firstSkipIndex);
                }

                if (SkipCountN != null && SkipCountN > 0)
                {
                    int skipCount = Math.Min((int)SkipCountN, chainSelections.Count);
                    chainSelections.RemoveRange(0, skipCount);
                }

                // Convert the computed SS block ranges to an AA selection and add that to list
                results.AddRange(chainSelections.Select(block => new Selection(chain[block.Start, block.End])));
            }

            return(results);
        }
Beispiel #17
0
        public List <IStructure> GetStructuresLinkedTo(IStructure structure)
        {
            var network = new List <IStructure>();

            using (Instrumenter.Start())
            {
                var frontier = new Queue <Coord>();
                frontier.Enqueue(structure.Coord);

                var closed = new List <Coord>();
                while (frontier.Count > 0)
                {
                    var current = frontier.Dequeue();
                    if (closed.Contains(current))
                    {
                        continue;
                    }
                    closed.Add(current);

                    if (TryGetStructureAtCoord(current, out IStructure linkedStructure))
                    {
                        if (!network.Contains(linkedStructure))
                        {
                            network.Add(linkedStructure);
                        }

                        if (linkedStructure.Type == StructureDefinition.StructureType.Road || linkedStructure.Type == StructureDefinition.StructureType.Core)
                        {
                            if (_mapManager.TryGetCellAtCoord(linkedStructure.Coord, out Cell cell))
                            {
                                foreach (var linkedCell in cell.GetCardinalNeighbours())
                                {
                                    if (!closed.Contains(linkedCell.Coord))
                                    {
                                        frontier.Enqueue(linkedCell.Coord);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(network);
        }
Beispiel #18
0
    public void Initialize(Vector2 _area, float _gridSize, GameObject _constructPrefab, Map _worldMap, ConstructionManager.ConstructType _constructType)
    {
        size = _area;
        AddToGrid();
        transform.gameObject.layer = 10;
        constructPrefab            = _constructPrefab;
        constructType     = _constructType;
        interactionRadius = ((size.x + size.y) / 2 * 1.5f) + 1.5f;

        IStructure structure = _constructPrefab.GetComponent <IStructure>(); //get maxhealth of the building and set it as the goal to reach

        maxHealth = structure.GetMaxHealth();

        SetSize(_gridSize);
        transform.gameObject.AddComponent <BoxCollider>().size   = new Vector3(size.x * _gridSize, 1.5f, size.y * _gridSize);
        transform.gameObject.GetComponent <BoxCollider>().center = new Vector3(0, 0.75f, 0);
        _worldMap.NavMeshUpdate();
    }
Beispiel #19
0
        private bool ShouldConnectRoad(IStructure sourceStructure, Position position)
        {
            if (!IsRoad(position.X, position.Y))
            {
                return(false);
            }

            if (sourceStructure == null)
            {
                return(true);
            }

            var structureAtNeighborRoad = regionManager.GetObjectsInTile(position.X, position.Y)
                                          .OfType <IStructure>()
                                          .FirstOrDefault();

            return(structureAtNeighborRoad == null);
        }
Beispiel #20
0
        /// <summary>
        ///     Changes a structure to a new type.
        /// </summary>
        public virtual void StructureChange(IStructure structure, ushort newType, byte newLvl, CallbackProcedure callbackProcedure, IStructureCsvFactory structureCsvFactory)
        {
            structure.City.BeginUpdate();
            structure.BeginUpdate();
            structure.IsBlocked = 0;
            structureCsvFactory.GetUpgradedStructure(structure, newType, newLvl);
            structure.Technologies.BeginUpdate();
            structure.Technologies.Parent = structure.City.Technologies;
            structure.Technologies.Clear();

            OnStructureUpgradeDowngrade(structure);

            structure.Technologies.EndUpdate();
            structure.EndUpdate();
            structure.City.EndUpdate();

            callbackProcedure.OnStructureConvert(structure);
        }
Beispiel #21
0
        public virtual int GetInstantTrainCount(IStructure structure)
        {
            var effectForStructureType =
                structure.City.Technologies.GetEffects(EffectCode.UnitTrainInstantTime).Where(x => (int)x.Value[0] == structure.Type).ToList();

            if (!effectForStructureType.Any())
            {
                return(0);
            }

            var units = structure.City.Troops.MyStubs().SelectMany(stub => stub.ToUnitList());

            var current = units.Sum(x => ObjectTypeFactory.IsObjectType((string)effectForStructureType[0].Value[1], x.Type) ? x.Count : 0);

            var threshold = Math.Min(effectForStructureType.Sum(x => (int)x.Value[2]), (int)effectForStructureType[0].Value[3]);

            return(Math.Max(threshold - current, 0));
        }
Beispiel #22
0
        public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            o2Mate.Expression expr = new o2Mate.Expression();
            this.directories = new List <string>();
            for (int index = 0; index < this.filePath.Count - 1; ++index)
            {
                string expression = this.filePath[index];
                string path       = Helper.ConvertNewExpression(this.cachedComp, proc, converter, expression, EnumDataType.E_STRING_OBJECT);
                this.directories.Add(path);
            }
            this.fileName = new List <string>();
            {
                string   expression = this.filePath[this.filePath.Count - 1];
                string[] split      = expression.Split('.');
                foreach (string s in split)
                {
                    string path = Helper.ConvertNewExpression(this.cachedComp, proc, converter, s, EnumDataType.E_STRING_OBJECT);
                    this.fileName.Add(path);
                }
            }

            if (proc.CurrentScope.Exists(this.writerName))
            {
                this.newWriter = proc.CurrentScope.GetVariable(this.writerName);
                if (this.newWriter.TypeExists(EnumDataType.E_WRITER))
                {
                    proc.CurrentScope.Update(this.writerName, "", this.newWriter.PrefixInfo(EnumDataType.E_WRITER).BelongsTo, false, EnumDataType.E_WRITER);
                    this.cachedComp.UpdateParameters(converter, proc, this.writerName, true);
                }
                else
                {
                    this.newWriter = proc.CurrentScope.Update(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                    IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                    converter.CurrentFunction.LocalVariables.Add(st);
                }
            }
            else
            {
                this.newWriter = proc.CurrentScope.Add(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                converter.CurrentFunction.LocalVariables.Add(st);
            }
            converter.Convert(this);
        }
        /// <summary> A match exists for the given name somewhere after the given position (in the
        /// normal serialization order).
        /// </summary>
        /// <param name="pos">the message position after which to look (note that this specifies
        /// the message instance)
        /// </param>
        /// <param name="name">the name of the structure to look for
        /// </param>
        /// <param name="firstDescendentsOnly">only searches the first children of a group
        /// </param>
        /// <param name="upToFirstRequired">only searches the children of a group up to the first
        /// required child (normally the first one).  This is used when we are parsing
        /// a message in order and looking for a place to parse a particular segment --
        /// if the message is correct then it can't go after a required position of a
        /// different name.
        /// </param>
        public static bool matchExistsAfterPosition(Position pos, String name, bool firstDescendentsOnly,
                                                    bool upToFirstRequired)
        {
            bool matchExists = false;

            //check next rep of self (if any)
            if (pos.parent.IsRepeating(pos.index.name))
            {
                IStructure s = pos.parent.GetStructure(pos.index.name, pos.index.rep);
                matchExists = contains(s, name, firstDescendentsOnly, upToFirstRequired);
            }

            //check later siblings (if any)
            if (!matchExists)
            {
                String[] siblings = pos.parent.Names;
                bool     after    = false;
                for (int i = 0; i < siblings.Length && !matchExists; i++)
                {
                    if (after)
                    {
                        matchExists = contains(pos.parent.GetStructure(siblings[i]), name, firstDescendentsOnly, upToFirstRequired);
                        if (upToFirstRequired && pos.parent.IsRequired(siblings[i]))
                        {
                            break;
                        }
                    }
                    if (pos.index.name.Equals(siblings[i]))
                    {
                        after = true;
                    }
                }
            }

            //recurse to parent (if parent is not message root)
            if (!matchExists && !typeof(IMessage).IsAssignableFrom(pos.parent.GetType()))
            {
                IGroup   grandparent = pos.parent.ParentStructure;
                Position parentPos   = new Position(grandparent, getIndex(grandparent, pos.parent));
                matchExists = matchExistsAfterPosition(parentPos, name, firstDescendentsOnly, upToFirstRequired);
            }
            log.Debug("Match exists after position " + pos + " for " + name + "? " + matchExists);
            return(matchExists);
        }
Beispiel #24
0
        internal void GenerateMaze(IStructure structure, Random random)
        {
            cancel         = false;
            this.structure = structure;
            if (_trackGenerationPath)
            {
                GenerationPath = new List <Cell>(structure.Count());
            }
            Stage?.Invoke(ProgressStage.Started, this.structure, 0);

            if (ProcessGenerating(random))
            {
                GenerationSuccessfull();
            }
            else
            {
                GenerationFailed();
            }
        }
        /// <summary>
        /// Examines an IEntity instance to see if any feature will be interested in it.
        /// </summary>
        /// <param name="entity">The IEntity instance to be examined.</param>
        private void ProcessEntity(IEntity entity)
        {
            if (entity == null)
            {
                return;
            }

            EntityTokenizer entityTokens = null;

            // Process structure data of the entity.
            IStructure structure = entity.Structure;

            if (structure != null)
            {
                //DarkCity.LogDebug($"Processing structure {structure.Entity.Name}");

                if (EmpyrionExtension.LiveLcd &&
                    ((EmpyrionExtension.Application.Mode == ApplicationMode.PlayfieldServer) || (EmpyrionExtension.Application.Mode == ApplicationMode.SinglePlayer)))
                {
                    // Process LCD devices.
                    IDevicePosList list = structure.GetDevices(DeviceTypeName.LCD);
                    if (list != null)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            Eleon.Modding.VectorInt3 position = list.GetAt(i);
                            ILcd lcd = structure.GetDevice <ILcd>(position);
                            if (lcd != null)
                            {
                                // Prep structure tokens if not available yet.
                                if (entityTokens == null)
                                {
                                    entityTokens = new EntityTokenizer(entity);
                                }

                                // Hand off ILcd device to any potentially interested processors.
                                LiveLcd.Process(structure, lcd, position, entityTokens, this.PlayfieldTokens);
                            }
                        }
                    }
                }
            }
        }
Beispiel #26
0
    private bool isStructureCloseEnough(IStructure structure)
    {
        if (structure == null || structure.isDestroyed())
        {
            return(false);
        }
        bool closeEnough = false;

        foreach (var pathNode in structure.getPathNodeList())
        {
            //Debug.Log("Distance: " + Vector2.Distance(transform.position, pathNode.getPos()));
            if (Vector2.Distance(transform.position, pathNode.getPos()) <= 1.1f)
            {
                closeEnough = true;
            }
        }

        return(closeEnough);
    }
Beispiel #27
0
    public void MineBlock(float hit, out bool destroyed, out IInventory loot, out int xp)
    {
        destroyed = true;
        loot      = null;
        xp        = 0;
        if (structure != null && structure is Block)
        {
            Block b = (Block)structure;

            b.Mine(hit, out destroyed);
            if (destroyed)
            {
                loot = b.getLoot();
                //Debug.Log("Loot: " + loot);
                xp        = b.getXpOnMine();
                Structure = null;
            }
        }
    }
Beispiel #28
0
 private void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (currentStructure == null && e.Key == Key.D && game.PlayerCash >= Wall.GetCost())
     {
         currentStructure = PurchaseStructure(typeof(Wall));
     }
     if (currentStructure == null && e.Key == Key.F && game.PlayerCash >= WaterTurret.GetCost())
     {
         currentStructure = PurchaseStructure(typeof(WaterTurret));
     }
     if (e.Key == Key.B)
     {
         RegretPurchase();
     }
     if (e.Key == Key.Tab)
     {
         RotateWall(currentStructure as Wall);
     }
 }
Beispiel #29
0
        public static bool StartsWith <T1, T2, T3>([NotNull] this IStructure structure, [CanBeNull] out T1 obj1, [CanBeNull] out T2 obj2,
                                                   [CanBeNull] out T3 obj3)
            where T1 : ZilObject
            where T2 : ZilObject
            where T3 : ZilObject
        {
            if (structure.HasLengthAtLeast(3) && structure[0] is T1 elem1 && structure[1] is T2 elem2 && structure[2] is T3 elem3)
            {
                obj1 = elem1;
                obj2 = elem2;
                obj3 = elem3;
                return(true);
            }

            obj1 = default;
            obj2 = default;
            obj3 = default;
            return(false);
        }
        /// <summary>
        /// Spawns IStructure:
        /// <para>- Adds structure to world</para>
        /// <para>- Registers building to faction</para>
        /// <para>- Subscribes Update to Game's onTick</para>
        /// <para>- If ConstructingBuilding, Registers finish-time</para>
        /// </summary>
        /// <param name="spawnCoords">Where to spawn, 'StartCoords'</param>
        /// <param name="structure">What to spawn</param>
        public virtual void SpawnStructure(Coords spawnCoords, IStructure <IStructureDef> structure)
        {
            structure.StartCoords = spawnCoords;

            World.AddStructure(structure);

            structure.Faction.RegisterBuilding(structure);

            Game.onTick += structure.Update;

            if (!(structure is ConstructingBuildingController))
            {
                return;
            }

            ConstructingBuildingController constructingBuilding = (ConstructingBuildingController)structure;

            constructingBuilding.ConstructingBuildingModel.FinishTime = (int)(constructingBuilding.Def.ConstructionTime + Game.LastUpdateGameTime.TotalGameTime.TotalSeconds);
        }
Beispiel #31
0
        private StructureDefinition CreateStructureDefinition(IStructure theStructure, ref StructureDefinition thePreviousLeaf)
        {
            var result = new StructureDefinition
            {
                Name = theStructure.GetStructureName(),
            };

            if (theStructure is IGroup)
            {
                result.IsSegment = false;
                var group      = (IGroup)theStructure;
                var index      = 0;
                var childNames = group.Names.ToList();

                foreach (var nextName in childNames)
                {
                    var nextChild           = group.GetStructure(nextName);
                    var structureDefinition = CreateStructureDefinition(nextChild, ref thePreviousLeaf);

                    structureDefinition.NameAsItAppearsInParent = nextName;
                    structureDefinition.IsRepeating             = group.IsRepeating(nextName);
                    structureDefinition.IsRequired      = group.IsRequired(nextName);
                    structureDefinition.IsChoiceElement = group.IsChoiceElement(nextName);
                    structureDefinition.Position        = index++;
                    structureDefinition.Parent          = result;

                    result.Children.Add(structureDefinition);
                }
            }
            else
            {
                if (thePreviousLeaf != null)
                {
                    thePreviousLeaf.NextLeaf = result;
                }

                thePreviousLeaf  = result;
                result.IsSegment = true;
            }

            return(result);
        }
Beispiel #32
0
        public void GetInstantTrainCount_WhenEffectIsUnderCapacity([Frozen] IObjectTypeFactory objectTypeFactory,
                                                                   Formula formula,
                                                                   IStructure structure)
        {
            var effects = new List <Effect>
            {
                new Effect
                {
                    Id        = EffectCode.UnitTrainInstantTime,
                    IsPrivate = false,
                    Location  = EffectLocation.City,
                    Value     = new object[] { 1, "BarrackUnits", 50, 50 }
                }
            };

            structure.City.Technologies.GetEffects(EffectCode.UnitTrainInstantTime).Returns(effects);
            objectTypeFactory.IsObjectType("BarrackUnits", 101).Returns(true);
            structure.Type.Returns((ushort)1);
            formula.GetInstantTrainCount(structure).Should().Be(50);
        }
Beispiel #33
0
 /// <summary>
 /// Processes the structure.
 /// A base structure can be either a segment, or segment group. This function
 /// determines which it is before passing it on.
 /// </summary>
 /// <param name="structure">The structure.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 private static void ProcessStructure(IStructure structure, FieldGroup parentNode)
 {
     if (structure.GetType().IsSubclassOf(typeof(AbstractSegment)))
     {
         AbstractSegment seg = (AbstractSegment)structure;
         ProcessSegment(seg, parentNode);
     }
     else if (structure.GetType().IsSubclassOf(typeof(AbstractGroup)))
     {
         AbstractGroup structureGroup = (AbstractGroup)structure;
         ProcessStructureGroup(structureGroup, parentNode);
     }
     else
     {
         parentNode.FieldList.Add(new FieldGroup()
         {
             Name = "Something Else!!!"
         });
     }
 }
Beispiel #34
0
        public object GetValue(IStructure structure)
        {
            if (!structure.Properties.Contains(Name))
            {
                return(GetDefaultValue());
            }

            if (Origin == PropertyOrigin.Formula)
            {
                MethodInfo method = typeof(Formula).GetMethod(Name);
                return(method.Invoke(null, new object[] { structure }));
            }

            if (Origin == PropertyOrigin.System)
            {
                return(systemVariableManager[Name].Value);
            }

            return(structure[Name]);
        }
Beispiel #35
0
        /// <summary> Returns an array of Structure objects by name.  For example, if the Group contains
        /// an MSH segment and "MSH" is supplied then this call would return a 1-element array
        /// containing the MSH segment.  Multiple elements are returned when the segment or
        /// group repeats.  The array may be empty if no repetitions have been accessed
        /// yet using the get(...) methods.
        /// </summary>
        /// <throws>  HL7Exception if the named Structure is not part of this Group.  </throws>
        public virtual IStructure[] GetAll(string name)
        {
            var item = GetGroupItem(name);

            if (item == null)
            {
                throw new HL7Exception(
                          $"The structure {name} does not exist in the group {GetType().FullName}",
                          ErrorCode.APPLICATION_INTERNAL_ERROR);
            }

            var all = new IStructure[item.Structures.Count];

            for (var i = 0; i < item.Structures.Count; i++)
            {
                all[i] = item.Structures[i];
            }

            return(all);
        }
Beispiel #36
0
    void Start()
    {
        pathNodeGrid = new Grid <PathNode>((int)gridSize.x, (int)gridSize.y, 1f, Vector3.zero,
                                           (Grid <PathNode> g, int x, int y) => new PathNode(g, x, y));

        Vector2 siloPos = new Vector2(0, 0);

        GameObject siloGameObject = Instantiate(SiloPrefab);
        IStructure silo           = siloGameObject.GetComponent <Silo>();

        silo.InstantiateBlock(siloPos.x, siloPos.y);
        addStructureToGrid(silo);

        new JobController();       // its yellow but leave it, its fine

        Vector2    SawPos        = new Vector2(0, 2);
        GameObject sawGameObject = Instantiate(SawPrefab);
        Saw        saw           = sawGameObject.GetComponent <Saw>();

        saw.InstantiateBlock(SawPos.x, SawPos.y, 2, Processor.Tier.Bronze);
        addProcessorToGrid(saw);



        Vector2      minerStationPos        = new Vector2(2, 0);
        GameObject   minerStationGameObject = Instantiate(MinerStationPrefab);
        MinerStation minerStation           = minerStationGameObject.GetComponent <MinerStation>();

        minerStation.InstantiateBlock(minerStationPos.x, minerStationPos.y);
        addStructureToGrid(minerStation);



        /*
         * Vector2 secondminerStationPos = new Vector2(0, 4);
         * MinerStation secondminerStation = new MinerStation(secondminerStationPos.x, secondminerStationPos.y, this);
         * pathNodeGrid.GetGridObject(secondminerStationPos).SetStructure(secondminerStation);
         */

        //GenerateBay();
    }
Beispiel #37
0
        /* for configurability (maybe to add later, replacing hard-coded options
         * in nextFromEndOfGroup) ...
         * public void setSearchLevel(String level) {
         * if (WHOLE_GROUP.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = false;
         * } else if (FIRST_DESCENDENTS_ONLY.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = true;
         * } else if (UP_TO_FIRST_REQUIRED.equals(level)) {
         * this.findUpToFirstRequired = true;
         * this.findFirstDescendentsOnly = false;
         * } else {
         * throw IllegalArgumentException(level + " is not a valid search level.  Should be WHOLE_GROUP, etc.");
         * }
         * }
         *
         * public String getSearchLevel() {
         * String level = WHOLE_GROUP;
         * if (this.findFirstDescendentsOnly) {
         * level = FIRST_DESCENDENTS_ONLY;
         * } else if (this.findUpTpFirstRequired) {
         * level = UP_TO_FIRST_REQUIRED;
         * }
         * return level;
         * }*/

        #region Public Methods and Operators

        /// <summary>
        /// Determines whether the given structure matches the given name, or contains a child that does.
        /// </summary>
        ///
        /// <exception cref="ApplicationException"> Thrown when an Application error condition occurs. </exception>
        ///
        /// <param name="s">                    the structure to check. </param>
        /// <param name="name">                 the name to look for. </param>
        /// <param name="firstDescendentsOnly"> only checks first descendents (i.e. first child, first
        ///                                     child of first child, etc.)  In theory the first child of
        ///                                     a group should always be present, and we don't use this
        ///                                     method with subsequent children because finding the next
        ///                                     position within a group is straightforward.  </param>
        /// <param name="upToFirstRequired">    only checks first descendents and of their siblings up to
        ///                                     the first required one.  This may be needed because in
        ///                                     practice some first children of groups are not required.  </param>
        ///
        /// <returns>   true if the object is in this collection, false if not. </returns>

        public static bool contains(IStructure s, System.String name, bool firstDescendentsOnly, bool upToFirstRequired)
        {
            bool contains = false;

            if (typeof(ISegment).IsAssignableFrom(s.GetType()))
            {
                if (s.GetStructureName().Equals(name))
                {
                    contains = true;
                }
            }
            else
            {
                IGroup          g     = (IGroup)s;
                System.String[] names = g.Names;
                for (int i = 0; i < names.Length && !contains; i++)
                {
                    try
                    {
                        contains = MessageIterator.contains(
                            g.GetStructure(names[i], 0),
                            name,
                            firstDescendentsOnly,
                            upToFirstRequired);
                        if (firstDescendentsOnly)
                        {
                            break;
                        }
                        if (upToFirstRequired && g.IsRequired(names[i]))
                        {
                            break;
                        }
                    }
                    catch (HL7Exception e)
                    {
                        throw new System.ApplicationException("HL7Exception due to bad index: " + e.Message);
                    }
                }
            }
            return(contains);
        }
Beispiel #38
0
        public void Test_ShouldAlterCurrency_WhenDayPassed()
        {
            //TODO
            //    Arrange
            Faction_Controller faction = new Faction_Controller("test", game, 500);

            Mock <IStructure <IStructureDef> > structureMock = new Mock <IStructure <IStructureDef> >();

            structureMock.SetupGet(structureParam => structureParam.Def).Returns(new BuildingDef()
            {
                UpkeepCost = 100
            });
            IStructure <IStructureDef> structure = structureMock.Object;

            faction.RegisterBuilding(structure);

            //    Act
//            game.TimeController = new TimeController();

            //    Assert
        }
 public virtual void NotifyUpdated(ISession session, IStructureSchema schema, IStructure structure, object item)
 {
     foreach (var handler in OnUpdatedHandlers)
         handler.Invoke(session, schema, structure, item);
 }
 void IField.SetFieldData(byte[] field_data, IStructure caller)
 {
     tag_class = (TagClass)BitConverter.ToInt32(field_data, 0);
     tag_identifier = BitConverter.ToInt32(field_data, 4);
 }
 void IField.Initialize(IStructure calling_structure)
 {
     parent = calling_structure;
 }
Beispiel #42
0
        /* may add configurability later ...
        private boolean findUpToFirstRequired;
        private boolean findFirstDescendentsOnly;

        public static final String WHOLE_GROUP;
        public static final String FIRST_DESCENDENTS_ONLY;
        public static final String UP_TO_FIRST_REQUIRED;
        */
        /// <summary>Creates a new instance of MessageIterator </summary>
        public MessageIterator(IStructure start, System.String direction, bool handleUnexpectedSegments)
        {
            this.currentStructure = start;
            this.direction = direction;
            this.handleUnexpectedSegments = handleUnexpectedSegments;
        }
Beispiel #43
0
 /// <summary>
 /// Processes the structure.
 /// A base structure can be either a segment, or segment group. This function
 /// determines which it is before passing it on.
 /// </summary>
 /// <param name="structure">The structure.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 private void ProcessStructure(IStructure structure, FieldGroup parentNode)
 {
     if (structure.GetType().IsSubclassOf(typeof(AbstractSegment)))
     {
         AbstractSegment seg = (AbstractSegment)structure;
         this.ProcessSegment(seg, parentNode);
     }
     else if (structure.GetType().IsSubclassOf(typeof(AbstractGroup)))
     {
         AbstractGroup structureGroup = (AbstractGroup)structure;
         this.ProcessStructureGroup(structureGroup, parentNode);
     }
     else
     {
         parentNode.FieldList.Add(new Field() { Name = "Something Else!!!" });
     }
 }
Beispiel #44
0
 /// <summary>
 /// Adding a new item to a chunk file in multithread mode
 /// </summary>
 /// <param name="filepath">path to a file</param>
 /// <param name="ds">datastructure</param>
 public static void AddItem( string filepath, IStructure ds )
 {
     if ( ds != null ) {
         var sw = new StreamWriter( File.Open( filepath, FileMode.Append ) );
         using (var json_writer = new JsonTextWriter(sw)) {
             var elem= new InnerChunkElement();
             if ( ds is Record ) {
                 elem.ElementType = InnerChunkElement.ElemType.RECORD;
                 elem.ElemParentName = ((Record)ds).OwnerDC.Name;
                 elem.ElemParentHash = ((Record)ds).OwnerDC.GetIndex().DwarfHashCode;
                 elem.Contents = JsonConvert.SerializeObject(ds, Formatting.Indented );
             } else if ( ds is DataContainer ) {
                 elem.ElementType = InnerChunkElement.ElemType.DATACONTAINER;
                 elem.ElemDB = ((DataContainer)ds).GetOwnerDB().Name;
                 elem.ElemParentName = null;
                 elem.ElemParentHash = null;
                 elem.ElementName = ((DataContainer)ds).Name;
                 var ds_sec = (DataContainer)ds;
                 elem.Contents = JsonConvert.SerializeObject(ds_sec, Formatting.Indented);
             }
             elem.ElementHash = ds.GetIndex().DwarfHashCode;
             sw.Write(JsonConvert.SerializeObject(elem, Formatting.Indented));
         }
     } else {
         Errors.Messages.DisplayError( "DataStructure object is null!", "", "", DateTime.Now);
     }
 }
Beispiel #45
0
 /// <summary> Returns the index of the given structure as a child of the 
 /// given parent.  Returns null if the child isn't found. 
 /// </summary>
 public static Index getIndex(IGroup parent, IStructure child)
 {
     Index index = null;
     System.String[] names = parent.Names;
     for (int i = 0; i < names.Length; i++)
     {
         if (names[i].StartsWith(child.GetStructureName()))
         {
             try
             {
                 IStructure[] reps = parent.GetAll(names[i]);
                 for (int j = 0; j < reps.Length; j++)
                 {
                     if (child == reps[j])
                     {
                         index = new Index(names[i], j);
                         break;
                     }
                 }
             }
             catch (HL7Exception e)
             {
                 log.Error("", e);
                 throw new System.ApplicationException("Internal HL7Exception finding structure index: " + e.Message);
             }
         }
     }
     return index;
 }
Beispiel #46
0
 private void ParseRep(System.Xml.XmlElement theElem, IStructure theObj)
 {
     if (theObj is IGroup)
     {
         Parse((IGroup)theObj, theElem);
     }
     else if (theObj is ISegment)
     {
         Parse((ISegment)theObj, theElem);
     }
     log.Debug("Parsed element: " + theElem.Name);
 }
        protected virtual IndexInsertAction[] CreateGroupedIndexInsertActions(IStructureSchema structureSchema, IStructure[] structures)
        {
            var indexesTableNames = structureSchema.GetIndexesTableNames();
            var insertActions = new Dictionary<DataTypeCode, IndexInsertAction>(indexesTableNames.All.Length);
            foreach (var group in structures.SelectMany(s => s.Indexes).GroupBy(i => i.DataTypeCode))
            {
                var insertAction = CreateIndexInsertActionGroup(structureSchema, indexesTableNames, group.Key, group.ToArray());
                if (insertAction.HasData)
                    insertActions.Add(group.Key, insertAction);
            }

            var mergeStringsAndEnums = insertActions.ContainsKey(DataTypeCode.String) && insertActions.ContainsKey(DataTypeCode.Enum);
            if (mergeStringsAndEnums)
            {
                var strings = insertActions[DataTypeCode.String];
                var enums = insertActions[DataTypeCode.Enum];
                insertActions.Remove(DataTypeCode.Enum);

                insertActions[DataTypeCode.String] = CreateIndexInsertActionGroup(structureSchema, indexesTableNames, DataTypeCode.String, strings.Data.MergeWith(enums.Data).ToArray());
            }

            return insertActions.Values.ToArray();
        }
Beispiel #48
0
        public static IStructure FindItem( JsonReader json_reader, IStructure ds )
        {
            var item = new InnerChunkElement();
            while ( json_reader.Read() ) {
                item = json_serializer.Deserialize<InnerChunkElement>( json_reader );
                if ( item.ElementHash == ds.GetIndex().DwarfHashCode ) {
                    return ds;
                }
            }

            return null;
        }
Beispiel #49
0
 /// <summary>
 /// Creates a new index
 /// </summary>
 /// <param name="_index_object">Object for indexing</param>
 /// <returns></returns>
 public static Index CreateNew( IStructure _index_object )
 {
     if ( _index_object == null )
         throw new IndexException( "object for indexing is NULL" );
     return new Index( _index_object );
 }
Beispiel #50
0
        /// <summary>
        /// Getting several elements from a chunk file in multithread mode
        /// </summary>
        /// <param name="filepath">path to file</param>
        /// <param name="idx_arr">indexes array</param>
        public static IStructure[] GetItemRange( string filepath, Index[] idx_arr )
        {
            var ret_arr = new IStructure[0];

            var tmp_path = CreateTemporaryFile( filepath );

            using (var json_reader = new JsonTextReader(new StreamReader(File.Open( tmp_path, FileMode.Open )))) {
                json_reader.SupportMultipleContent = true;
                foreach ( var index in idx_arr ) {
                    var elem = GetItemInfile( json_reader, index );
                    if ( elem != null ) {
                        Array.Resize( ref ret_arr, ret_arr.Length + 1 );
                        ret_arr[ret_arr.Length-1] = elem;
                    }
                }
            }

            DeleteTemporaryFile( tmp_path );

            return ret_arr;
        }
Beispiel #51
0
        public bool TryRemove(IStructure data)
        {
            if (items_dict.ContainsKey(data.GetIndex().DwarfHashCode))
            {
                IStructure dummy = null;
                return items_dict.TryRemove(data.GetIndex().DwarfHashCode, out dummy);
            }

            return false;
        }
Beispiel #52
0
        /// <summary>
        /// Saving an existant item to a chunk file in multithread mode
        /// </summary>
        /// <param name="filepath">path to a file</param>
        /// <param name="ds">datastructure</param>
        public static void SaveItemContents( string filepath, IStructure ds )
        {
            var elem= new InnerChunkElement();
            if ( ds != null ) {
                var sw_read = new StreamReader( File.Open( filepath, FileMode.Open ) );
                InnerChunkElement icm = null;

                using ( var json_reader = new JsonTextReader(sw_read) ) {
                    icm = FindItem( json_reader, ds.GetIndex().DwarfHashCode );
                }

                if ( icm == null )
                {
                    Errors.Messages.DisplayError("Can't find such item!", "Saving an item", "", DateTime.Now);
                    return;
                }

                var sw_write = new StreamWriter( File.Open( filepath, FileMode.Append ) );
                using (var json_writer = new JsonTextWriter(sw_write)) {
                    if ( ds is Record ) {
                        icm.Contents = JsonConvert.SerializeObject(ds, Formatting.Indented );
                    } else if ( ds is DataContainer ) {
                        icm.Contents = JsonConvert.SerializeObject(ds as DataContainer, Formatting.Indented);
                    }
                    elem.ElementHash = ds.GetIndex().DwarfHashCode;
                    sw_write.Write(JsonConvert.SerializeObject(elem, Formatting.Indented));
                }
            } else {
                Errors.Messages.DisplayError( "DataStructure object is null!", "", "", DateTime.Now);
            }
        }
 public virtual void NotifyUpdated(ISession session, IStructureSchema schema, IStructure[] structures, object[] items)
 {
     for (var i = 0; i < structures.Length; i++)
         NotifyUpdated(session, schema, structures[i], items[i]);
 }
Beispiel #54
0
 /// <summary> Determines whether the given structure matches the given name, or contains 
 /// a child that does.  
 /// </summary>
 /// <param name="s">the structure to check 
 /// </param>
 /// <param name="name">the name to look for 
 /// </param>
 /// <param name="firstDescendentsOnly">only checks first descendents (i.e. first 
 /// child, first child of first child, etc.)  In theory the first child 
 /// of a group should always be present, and we don't use this method with 
 /// subsequent children because finding the next position within a group is 
 /// straightforward.  
 /// </param>
 /// <param name="upToFirstRequired">only checks first descendents and of their siblings 
 /// up to the first required one.  This may be needed because in practice 
 /// some first children of groups are not required.  
 /// </param>
 public static bool contains(IStructure s, System.String name, bool firstDescendentsOnly, bool upToFirstRequired)
 {
     bool contains = false;
     if (typeof(ISegment).IsAssignableFrom(s.GetType()))
     {
         if (s.GetStructureName().Equals(name))
             contains = true;
     }
     else
     {
         IGroup g = (IGroup)s;
         System.String[] names = g.Names;
         for (int i = 0; i < names.Length && !contains; i++)
         {
             try
             {
                 contains = MessageIterator.contains(g.GetStructure(names[i], 0), name, firstDescendentsOnly, upToFirstRequired);
                 if (firstDescendentsOnly)
                     break;
                 if (upToFirstRequired && g.IsRequired(names[i]))
                     break;
             }
             catch (HL7Exception e)
             {
                 throw new System.ApplicationException("HL7Exception due to bad index: " + e.Message);
             }
         }
     }
     return contains;
 }
Beispiel #55
0
 /// <summary> Returns an array of Structure objects by name.  For example, if the Group contains
 /// an MSH segment and "MSH" is supplied then this call would return a 1-element array 
 /// containing the MSH segment.  Multiple elements are returned when the segment or 
 /// group repeats.  The array may be empty if no repetitions have been accessed
 /// yet using the get(...) methods. 
 /// </summary>
 /// <throws>  HL7Exception if the named Structure is not part of this Group.  </throws>
 public virtual IStructure[] GetAll(System.String name)
 {
     AbstractGroupItem item = GetGroupItem(name);
     if (item == null)
         throw new HL7Exception("The structure " + name + " does not exist in the group " + this.GetType().FullName, HL7Exception.APPLICATION_INTERNAL_ERROR);
     IStructure[] all = new IStructure[item.Structures.Count];
     for (int i = 0; i < item.Structures.Count; i++)
     {
         all[i] = item.Structures[i];
     }
     return all;
 }
Beispiel #56
0
 public Index( IStructure _index_object )
 {
     index_object = _index_object;
 }
Beispiel #57
0
 private Index()
 {
     index_object = null;
 }
Beispiel #58
0
        /// <summary> Navigates to a specific location in the message</summary>
        private void drillHere(IStructure destination)
        {
            IStructure pathElem = destination;
            System.Collections.ArrayList pathStack = new System.Collections.ArrayList();
            System.Collections.ArrayList indexStack = new System.Collections.ArrayList();
            do
            {
                MessageIterator.Index index = MessageIterator.getIndex(pathElem.ParentStructure, pathElem);
                indexStack.Add(index);
                pathElem = pathElem.ParentStructure;
                pathStack.Add(pathElem);
            }
            while (!root.Equals(pathElem) && !typeof(IMessage).IsAssignableFrom(pathElem.GetType()));

            if (!root.Equals(pathElem))
            {
                throw new HL7Exception("The destination provided is not under the root of this navigator");
            }

            this.reset();
            while (!(pathStack.Count == 0))
            {
                IGroup parent = (IGroup)SupportClass.StackSupport.Pop(pathStack);
                MessageIterator.Index index = (MessageIterator.Index)SupportClass.StackSupport.Pop(indexStack);
                int child = search(parent.Names, index.name);
                if (!(pathStack.Count == 0))
                {
                    this.drillDown(child, 0);
                }
                else
                {
                    this.toChild(child);
                }
            }
        }
 public void Add(IStructure structure)
 {
     _structures.Add(structure);
 }
        protected virtual void InsertUniques(IStructureSchema structureSchema, IStructure[] structures)
        {
            if (!structures.Any())
                return;

            var uniques = structures.SelectMany(s => s.Uniques).ToArray();
            if (!uniques.Any())
                return;

            if (uniques.Length == 1)
                MainDbClient.SingleInsertOfUniqueIndex(uniques[0], structureSchema);
            else
                MainDbClient.BulkInsertUniques(structureSchema, uniques);
        }