예제 #1
0
 /// <summary>
 /// 创建分组列表缓存
 /// </summary>
 /// <typeparam name="keyType"></typeparam>
 /// <param name="getKey">字典关键字获取器</param>
 /// <param name="isRemoveEnd">分组关键字获取器</param>
 /// <param name="isReset">是否初始化数据</param>
 /// <param name="isSave">是否保存缓存对象防止被垃圾回收</param>
 /// <returns></returns>
 public DictionaryList<valueType, modelType, keyType> CreateDictionaryList<keyType>(Func<valueType, keyType> getKey, bool isRemoveEnd = false, bool isReset = true, bool isSave = false)
     where keyType : IEquatable<keyType>
 {
     DictionaryList<valueType, modelType, keyType> cache = new DictionaryList<valueType, modelType, keyType>(this, getKey, isRemoveEnd, isReset);
     if (isSave) memberCaches.Add(cache);
     return cache;
 }
예제 #2
0
 private void SetSchemeData(TableSchemeData schemaData)
 {
     fKeyFieldInfos = schemaData.KeyFieldInfos;
     fKeyFieldArray = schemaData.KeyFieldArray;
     Fields         = schemaData.SelectFields;
     KeyCount       = fKeyFieldInfos.Count;
 }
예제 #3
0
 public static void CheckStorage()
 {
     try
     {
         LinkedList <Chunk> chunkArray = null;
         DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
         ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
         for (int i = 0; i < chunklist.Count; i++)
         {
             ChunkCluster chunk = chunklist[i];
             chunkArray = chunk.GetChunkArray();
             if (chunkArray != null)
             {
                 foreach (Chunk c in chunkArray)
                 {
                     tiles = c.GetTileEntities();
                     if (tiles != null)
                     {
                         foreach (TileEntity tile in tiles.dict.Values)
                         {
                             if (tile.GetTileEntityType().ToString().Equals("SecureLoot"))
                             {
                                 TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                 if (GameManager.Instance.adminTools.GetUserPermissionLevel(SecureLoot.GetOwner()) > Admin_Level)
                                 {
                                     ItemStack[] items      = SecureLoot.items;
                                     int         slotNumber = 0;
                                     foreach (ItemStack item in items)
                                     {
                                         if (!item.IsEmpty())
                                         {
                                             string itemName = ItemClass.list[item.itemValue.type].Name;
                                             if (Dict.Contains(itemName))
                                             {
                                                 ItemStack itemStack = new ItemStack();
                                                 SecureLoot.UpdateSlot(slotNumber, itemStack.Clone());
                                                 tile.SetModified();
                                                 Vector3i _chestPos = SecureLoot.localChunkPos;
                                                 using (StreamWriter sw = new StreamWriter(DetectionFilepath, true, Encoding.UTF8))
                                                 {
                                                     sw.WriteLine("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString);
                                                 }
                                                 Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString));
                                             }
                                         }
                                         slotNumber++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in InvalidItems.CheckStorage: {0}", e.Message));
     }
 }
 public MetaMetadataCompositeField(String name, DictionaryList<String, MetaMetadataField> kids)
 {
     this.Name = name;
     this.Kids = new DictionaryList<String, MetaMetadataField>();
     if (kids != null)
         this.Kids.PutAll(kids);
 }
예제 #5
0
        public DictionaryList<Point, ConsoleEntityView> AllEntities()
        {
            var locs = new DictionaryList<Point, ConsoleEntityView>();
            Size wbSize = this.model.BurstSize;

            if (focus == null || focus.Module<VisionModule>().Vision == null)
            {

                foreach (KeyValuePair<XmasEntity, ConsoleEntityView> kv in viewlookup)
                {
                    Point p = ((TilePosition) kv.Value.Position).Point;
                    Point transp = new Point(p.X + wbSize.Width, p.Y + wbSize.Height);

                    locs.Add(transp, kv.Value);
                }
            }
            else
            {
                var vision = focus.Module<VisionModule>();

                foreach (var kv in vision.Vision.VisibleTiles)
                {
                    Point p = kv.Key;
                    Point transp = new Point(p.X + wbSize.Width, p.Y + wbSize.Height);
                    foreach (var ent in kv.Value.Entities)
                    {
                        ConsoleEntityView vent;
                        if(viewlookup.TryGetValue(ent,out vent))
                            locs.Add(transp, vent);
                    }
                }
            }
            return locs;
        }
예제 #6
0
 public void Dispose()
 {
     inner_data.Clear();
     categories.Clear();
     inner_data = null;
     categories = null;
 }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dimensions">Canvas dimentions.</param>
        /// <param name="items"></param>
        /// <returns></returns>
        public DictionaryList <int, long> CalculateRows(FloatPoint dimensions, DICT <long, FloatRect> items)
        {
            this.Dimensions = dimensions;
            int   rowIndex      = 0;
            float rowTotalWidth = 0;
            DictionaryList <int, long> newRow = new DictionaryList <int, long>();
            List <long> newRowIndex           = new List <long>();

            foreach (long l in items.Keys)
            {
                if (HasColumnWidth(items[l], rowTotalWidth, dimensions.X))
                {
                    newRowIndex.Add(l);
                    rowTotalWidth += items[l].Width;
                }
                else
                {
                    newRow.Add(rowIndex++, new List <long>(newRowIndex.ToArray()));
                    newRowIndex.Clear();
                    rowTotalWidth = 0;
                    newRowIndex.Add(l);
                    rowTotalWidth += items[l].Width;
                }
            }
            newRow.Add(rowIndex++, new List <long>(newRowIndex.ToArray()));
            rowsAndColumns = newRow;
            Rows           = GetRowHeights(items).ToArray();   // we could have gotten these?
            return(newRow);
        }
예제 #8
0
    public void ScanForTileEntityInList()
    {
        DisplayLog("ScanForTileEntityInList()");
        this.lstTileContainers.Clear();
        Vector3i blockPosition = this.theEntity.GetBlockPosition();

        var minX = prefab.boundingBoxPosition.x;
        var maxX = prefab.boundingBoxPosition.x + prefab.boundingBoxSize.x - 1;

        var minZ = prefab.boundingBoxPosition.z;
        var maxZ = prefab.boundingBoxPosition.z + prefab.boundingBoxSize.z - 1;

        int num  = World.toChunkXZ(blockPosition.x);
        int num2 = World.toChunkXZ(blockPosition.z);

        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                Chunk chunk = (Chunk)theEntity.world.GetChunkSync(num + j, num2 + i);
                if (chunk != null)
                {
                    var chunkPos = chunk.GetWorldPos();
                    var worldX   = chunkPos.x + i;
                    var worldZ   = chunkPos.z + j;

                    // Out of bounds
                    if (worldX < minX || worldX > maxX || worldZ < minZ || worldZ > maxZ)
                    {
                        continue;
                    }

                    // Grab all the Tile Entities in the chunk
                    DictionaryList <Vector3i, TileEntity> tileEntities = chunk.GetTileEntities();
                    for (int k = 0; k < tileEntities.list.Count; k++)
                    {
                        TileEntityLootContainer tileEntity = tileEntities.list[k] as TileEntityLootContainer;
                        if (tileEntity != null)
                        {
                            BlockValue block = theEntity.world.GetBlock(tileEntity.ToWorldPos());
                            if (tileEntity.bTouched)
                            {
                                DisplayLog(" This tile Entity has already been touched: " + tileEntities.ToString());
                                continue;
                            }

                            if (Block.list[block.type].HasTag(BlockTags.Door))
                            {
                                DisplayLog(" This tile entity is a door. ignoring.");
                                continue;
                            }
                            DisplayLog(" Loot Container: " + tileEntity.ToString() + " Distance: " + Vector3.Distance(tileEntity.ToWorldPos().ToVector3(), this.theEntity.position));
                            this.lstTileContainers.Add(tileEntity);
                        }
                    }
                }
            }
        }
    }
예제 #9
0
 public static void CheckStorage()
 {
     try
     {
         LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
         DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
         ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
         for (int i = 0; i < chunklist.Count; i++)
         {
             ChunkCluster chunk = chunklist[i];
             chunkArray = chunk.GetChunkArray();
             foreach (Chunk _c in chunkArray)
             {
                 tiles = _c.GetTileEntities();
                 foreach (TileEntity tile in tiles.dict.Values)
                 {
                     if (tile.GetTileEntityType().ToString().Equals("SecureLoot"))
                     {
                         TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                         AdminToolsClientInfo          Admin      = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner());
                         if (Admin.PermissionLevel > Admin_Level)
                         {
                             ItemStack[] items      = SecureLoot.items;
                             int         slotNumber = 0;
                             foreach (ItemStack item in items)
                             {
                                 if (!item.IsEmpty())
                                 {
                                     string _itemName = ItemClass.list[item.itemValue.type].Name;
                                     if (dict.Contains(_itemName))
                                     {
                                         int       _count    = item.count;
                                         ItemStack itemStack = new ItemStack();
                                         SecureLoot.UpdateSlot(slotNumber, itemStack.Clone());
                                         Vector3i _chestPos = SecureLoot.localChunkPos;
                                         using (StreamWriter sw = new StreamWriter(_filepath, true))
                                         {
                                             sw.WriteLine("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner());
                                             sw.WriteLine();
                                             sw.Flush();
                                             sw.Close();
                                         }
                                         Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner()));
                                     }
                                 }
                                 slotNumber++;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in InventoryCheck.ChestCheck: {0}.", e.Message));
     }
 }
예제 #10
0
 internal static void Initialize()
 {
     if (null != registeredMethods)
     {
         return;
     }
     registeredMethods = new DictionaryList <string, RegisteredMatchIntent>();
     new Thread(RefreshAssemblies).Start();
 }
 public MetaMetadataCompositeField(String name, DictionaryList <String, MetaMetadataField> kids)
 {
     this.Name = name;
     this.Kids = new DictionaryList <String, MetaMetadataField>();
     if (kids != null)
     {
         this.Kids.PutAll(kids);
     }
 }
예제 #12
0
        public void AddDictionary(string dictionaryName, int UserId)
        {
            DictionaryList dictionaryItem = new DictionaryList();

            dictionaryItem.Name   = dictionaryName;
            dictionaryItem.UserId = UserId;
            _context.DictionaryList.Add(dictionaryItem);
            _context.SaveChanges();
        }
예제 #13
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            Log     = new TextBoxOutput(_logBox);
            Readers = new BlockingCollection <ReaderInfo>();
            Debtors = new BlockingCollection <DebtorInfo>();
            ReadersByStatus
                       = new DictionaryList <string, ReaderInfo>();
            Connection = new IrbisConnection();
        }
예제 #14
0
 private void InitTagClassDescriptorsArrayList(int initialSize)
 {
     if (polymorphClassDescriptors == null)
     {
         polymorphClassDescriptors = new DictionaryList <string, ClassDescriptor>(initialSize);
     }
     if (polymorphClasses == null)
     {
         polymorphClasses = new Dictionary <String, Type>(initialSize);
     }
 }
예제 #15
0
        private void DeleteDictionary(object param)
        {
            Dictionary       selectedDictionary = (Dictionary)((DataGrid)param).SelectedItem;
            MessageBoxResult messageBoxResult   = MessageBox.Show("Valóban törli?", "Törlés megerősítése", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                DictionaryList.Remove(selectedDictionary);
                ((TeacherDAL)_contextDal).DeleteDictionary(selectedDictionary);
            }
        }
예제 #16
0
	public void AddReference(int id, int fieldIndex) {
		if (objReferences == null) {
			objReferences = new DictionaryList<int, HashSetList<int>>();
		}
		HashSetList<int> subFields;
		if (!objReferences.TryGetValue(id, out subFields)) {
			subFields = new HashSetList<int>();
			objReferences[id] = subFields;
		}
		subFields.Add(fieldIndex);
	}
예제 #17
0
        protected void SortForDisplay()
        {
            DictionaryList <String, MetaMetadataField> childMetaMetadata = Kids;

            if (childMetaMetadata != null)
            {
                childMetaMetadata.ValuesInList.Sort(delegate(MetaMetadataField f1, MetaMetadataField f2) { return(-Math.Sign(f1.Layer - f2.Layer)); });
            }

            fieldsSortedForDisplay = true;
        }
예제 #18
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         fDataAdapter.SelectCommand.DisposeObject();
         fDataAdapter.DisposeObject();
         HostDataSet    = null;
         Context        = null;
         fKeyFieldInfos = null;
         fKeyFieldArray = null;
     }
 }
 /// <summary>
 /// リソースのゲット
 /// 無い場合はロード
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="directryName"></param>
 /// <param name="PrefabName"></param>
 /// <returns></returns>
 public T Get <T>(string directryName, string PrefabName)
 {
     // 既にロード済みなら
     if (DictionaryList.ContainsKey(PrefabName))
     {
         return(DictionaryList[PrefabName].GetComponent <T>());
     }
     else
     {
         var obj = Load(directryName, PrefabName);
         return(obj.GetComponent <T>());
     }
 }
예제 #20
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this);
     }
     //bulletPoolDic = new Dictionary<string, GameObject>();
     bulletPoolDicList = new DictionaryList <string, GameObject>();
 }
예제 #21
0
        public List <DatabaseSearchResult> Find(String searchText, String databaseName, Int32 limit, List <string> keywordsToHighligh)
        {
            var dbDictionary = DictionaryList.FirstOrDefault(x => x.DatabaseName == databaseName);

            if (dbDictionary == null)
            {
                dbDictionary = new DatabaseDictionary();
                dbDictionary.Initialise(databaseName);
                DictionaryList.Add(dbDictionary);
                FillDatabase(dbDictionary);
            }

            return(dbDictionary.Find(searchText, limit, keywordsToHighligh));
        }
예제 #22
0
        public void RefreshDatabase(String name)
        {
            var d = server.Databases[name];

            RefresDatabase(d);

            // remove hashed objects
            var dbDictionary = DictionaryList.FirstOrDefault(x => x.DatabaseName == name);

            if (dbDictionary != null)
            {
                DictionaryList.Remove(dbDictionary);
            }
        }
예제 #23
0
        private MethodInfo MatchGenericMethod(Type type, string memberName, IList <Type> arguments)
        {
            var potentialMatches = type.GetMethods(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy)
                                   .Where(m => m.Name.Equals(memberName, StringComparison.OrdinalIgnoreCase))
                                   .Where(m => m.IsGenericMethod)
                                   .Where(m => m.GetParameters().Length == arguments.Count());


            foreach (var genericMethodInfo in potentialMatches)
            {
                var genericVersion = ResolveGenericMethodParameters(genericMethodInfo);
                if (genericVersion != null)
                {
                    return(genericVersion);
                }
            }

            // check to see if the supplied types can be used to resolve the genericParamters
            MethodInfo ResolveGenericMethodParameters(MethodInfo potentialmatch)
            {
                //Match Generic arguments with the method arguments to find possible types
                //connect a <T> to a arguments (T item)
                DictionaryList <Type, Type> genericTargetTypes = new DictionaryList <Type, Type>();
                var methodParameters = potentialmatch.GetParameters();

                for (int i = 0; i < methodParameters.Count(); i++)
                {
                    if (methodParameters[i].ParameterType.IsGenericParameter)
                    {
                        genericTargetTypes.Add(methodParameters[i].ParameterType, arguments[i]);
                    }

                    if (methodParameters[i].ParameterType.IsGenericType)
                    {
                        genericTargetTypes.Add(methodParameters[i].ParameterType.GenericTypeArguments[0], arguments[i].GenericTypeArguments[0]);
                    }
                }
                //todo We need to check the the supplied types implement the generic where constraints

                var genericParameters = potentialmatch.GetGenericArguments();

                // todo we need to look at all posssible types and find their highest common ancestor
                // currently just assuming the first
                var typeArguments = genericParameters.Select(g => genericTargetTypes.Get(g).First());

                return(potentialmatch.MakeGenericMethod(typeArguments.ToArray()));
            }

            return(null);
        }
예제 #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fieldDescriptor"></param>
        public void MapTagClassDescriptors(FieldDescriptor fieldDescriptor)
        {
            DictionaryList <String, ClassDescriptor> tagClassDescriptors = fieldDescriptor.PolymorphClassDescriptors;

            if (tagClassDescriptors != null)
            {
                foreach (String tagName in tagClassDescriptors.Keys)
                {
                    MapTagToFdForTranslateFrom(tagName, fieldDescriptor);
                }
            }

            MapTagToFdForTranslateFrom(fieldDescriptor.TagName, fieldDescriptor);
        }
    /// <summary>
    /// リソースのロード
    /// </summary>
    /// <param name="directryName"></param>
    /// <param name="PrefabName"></param>
    /// <returns></returns>
    public GameObject Load(string directryName, string PrefabName)
    {
        var obj = Resources.Load(directryName + PrefabName) as GameObject;

        if (obj != null)
        {
            DictionaryList.Add(PrefabName, obj);
        }
        else
        {
            DebugLog.log("読み込み失敗 : " + PrefabName);
            Debug.Log("読み込み失敗 : " + PrefabName);
        }
        return(obj);
    }
예제 #26
0
 private void InitPolymorphicClassDescriptorsList(Int32 size)
 {
     if (polymorphClassDescriptors == null)
     {
         polymorphClassDescriptors = new DictionaryList <String, ClassDescriptor>(size);
     }
     if (polymorphClasses == null)
     {
         polymorphClasses = new Dictionary <String, Type>(size);
     }
     if (tlvClassDescriptors == null)
     {
         tlvClassDescriptors = new Dictionary <Int32, ClassDescriptor>(size);
     }
 }
예제 #27
0
        internal TableSchemeData(TkDbContext context, ITableScheme scheme)
        {
            ICacheDependencyCreator creator = scheme as ICacheDependencyCreator;

            if (creator != null)
            {
                fDependency = creator.CreateCacheDependency();
            }
            if (fDependency == null)
            {
                fDependency = (new ActiveTimeCacheAttribute()).CreateObject();
            }
            KeyFieldInfos = new DictionaryList <IFieldInfo>();

            ProcessFields(context, scheme);
        }
예제 #28
0
        public static void ChestCheck()
        {
            LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
            DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
            ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;

            for (int i = 0; i < chunklist.Count; i++)
            {
                ChunkCluster chunk = chunklist[i];
                chunkArray = chunk.GetChunkArray();
                foreach (Chunk _c in chunkArray)
                {
                    tiles = _c.GetTileEntities();
                    foreach (TileEntity tile in tiles.dict.Values)
                    {
                        TileEntityType type = tile.GetTileEntityType();
                        if (type.ToString().Equals("SecureLoot"))
                        {
                            TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                            AdminToolsClientInfo          Admin      = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner());
                            if (Admin.PermissionLevel > Admin_Level)
                            {
                                ItemStack[] items      = SecureLoot.items;
                                int         slotNumber = 0;
                                foreach (ItemStack item in items)
                                {
                                    if (!item.IsEmpty())
                                    {
                                        ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                        string    _itemName  = _itemClass.GetItemName();
                                        if (dict.Contains(_itemName))
                                        {
                                            int       _count    = item.count;
                                            ItemStack itemStack = new ItemStack();
                                            SecureLoot.UpdateSlot(slotNumber, itemStack);
                                            Vector3i _chestPos = SecureLoot.localChunkPos;
                                            Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a chest located at {2} {3} {4}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z));
                                        }
                                    }
                                    slotNumber++;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try
            {
                if (_params.Count != 1)
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found '{0}'", _params.Count));

                    return;
                }
                if (!string.IsNullOrEmpty(_senderInfo.RemoteClientInfo.CrossplatformId.CombinedString))
                {
                    LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
                    DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
                    ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                    for (int i = 0; i < chunklist.Count; i++)
                    {
                        ChunkCluster chunk = chunklist[i];
                        chunkArray = chunk.GetChunkArray();
                        foreach (Chunk _c in chunkArray)
                        {
                            tiles = _c.GetTileEntities();
                            foreach (TileEntity tile in tiles.dict.Values)
                            {
                                TileEntityType type = tile.GetTileEntityType();
                                if (type.ToString().Equals("SecureLoot"))
                                {
                                    TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                    if (!SecureLoot.IsUserAllowed(_senderInfo.RemoteClientInfo.CrossplatformId))
                                    {
                                        List <PlatformUserIdentifierAbs> _users = SecureLoot.GetUsers();
                                        _users.Add(_senderInfo.RemoteClientInfo.CrossplatformId);
                                        SecureLoot.SetModified();
                                    }
                                }
                            }
                        }
                    }
                }
                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Secure loot access set for '{0}' in all loaded areas. Unloaded areas have not changed", _senderInfo.RemoteClientInfo.CrossplatformId.CombinedString));
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in SecureLootAccessConsole.Execute: {0}", e.Message));
            }
        }
        public void TestAdd()
        {
            var newList = new DictionaryList<int>();

            Assert.AreEqual(0, newList.Count);

            newList.Add(1);
            Assert.AreEqual(1, newList.Count);
            Assert.AreEqual(1, newList[0]);

            newList.Add(3);
            Assert.AreEqual(2, newList.Count);
            Assert.AreEqual(1, newList[0]);
            Assert.AreEqual(3, newList[1]);

            newList[null] = 7;
            Assert.AreEqual(3, newList.Count);
            Assert.AreEqual(1, newList[0]);
            Assert.AreEqual(3, newList[1]);
            Assert.AreEqual(7, newList[2]);
            Assert.AreEqual(7, newList[null]);

            newList.Add(1, 9);
            Assert.AreEqual(4, newList.Count);
            Assert.AreEqual(1, newList[0]);
            Assert.AreEqual(9, newList[1]);
            Assert.AreEqual(3, newList[2]);
            Assert.AreEqual(7, newList[3]);

            newList.Add(null, 44);
            Assert.AreEqual(5, newList.Count);
            Assert.AreEqual(1, newList[0]);
            Assert.AreEqual(9, newList[1]);
            Assert.AreEqual(3, newList[2]);
            Assert.AreEqual(7, newList[3]);
            Assert.AreEqual(44, newList[4]);
            Assert.AreEqual(44, newList[null]);

            Assert.AreEqual(5, newList.Count);
            Assert.AreEqual(5, newList.Count);
            Assert.AreEqual(1, newList[0]);
            Assert.AreEqual(9, newList[1]);
            Assert.AreEqual(3, newList[2]);
            Assert.AreEqual(7, newList[3]);
            Assert.AreEqual(44, newList[4]);
        }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count != 1)
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found {0}", _params.Count));
             return;
         }
         if (!string.IsNullOrEmpty(_senderInfo.RemoteClientInfo.playerId))
         {
             LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
             DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
             ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
             for (int i = 0; i < chunklist.Count; i++)
             {
                 ChunkCluster chunk = chunklist[i];
                 chunkArray = chunk.GetChunkArray();
                 foreach (Chunk _c in chunkArray)
                 {
                     tiles = _c.GetTileEntities();
                     foreach (TileEntity tile in tiles.dict.Values)
                     {
                         TileEntityType type = tile.GetTileEntityType();
                         if (type.ToString().Equals("SecureDoor"))
                         {
                             TileEntitySecureDoor SecureDoor = (TileEntitySecureDoor)tile;
                             if (!SecureDoor.IsUserAllowed(_senderInfo.RemoteClientInfo.playerId))
                             {
                                 List <string> _users = SecureDoor.GetUsers();
                                 _users.Add(_senderInfo.RemoteClientInfo.playerId);
                                 SecureDoor.SetModified();
                             }
                         }
                     }
                 }
             }
         }
         SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Door access set for {0}", _senderInfo.RemoteClientInfo.playerId));
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in SecureDoorAccess.Execute: {0}", e.Message));
     }
 }
예제 #32
0
        internal static void RefreshAssemblies()
        {
            // TODO: We could potentially build this list at compile time and cache it
            // Work on a local dictionary to avoid thread complications
            var dictionary = new DictionaryList <string, RegisteredMatchIntent>();

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                try {
                    foreach (Type t in assembly.GetTypes())
                    {
                        try {
                            foreach (var method in t.GetMethods())
                            {
                                try {
                                    foreach (var attribute in method.GetCustomAttributes(typeof(MatchIntent)))
                                    {
                                        try {
                                            var mi = (MatchIntent)attribute;
                                            dictionary[mi.Intent].Add(new RegisteredMatchIntent()
                                            {
                                                type        = t,
                                                method      = method,
                                                matchIntent = mi
                                            });
                                        } catch (Exception e) {
                                            Debug.LogError(e);
                                        }
                                    }
                                } catch (Exception e) {
                                    Debug.LogError(e);
                                }
                            }
                        } catch (Exception e) {
                            Debug.LogError(e);
                        }
                    }
                } catch (Exception e) {
                    Debug.LogError(e);
                }
            }

            registeredMethods = dictionary;
        }
예제 #33
0
        public override void OnNavigateTo()
        {
            _dictionary.ItemClicked += DictionaryOnItemClicked;

            Header = string.Format(@"{0} ""{1}""", _resourcesProvider.GetResource("SearchResultsLabel"), _dictionary.SearchQuery);

            DictionaryList selectedList = _parametersManager.Get <DictionaryList>(Parameters.SelectedSearchResultsList);

            if (selectedList != null)
            {
                CurrentList = selectedList;
            }
            else if (Dictionary.SearchResults.Count > 0)
            {
                CurrentList = Dictionary.SearchResults[0];
            }
            else
            {
                CurrentList = null;
            }
        }
        public void ClearWorksFine()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 }
            };

            Assert.AreEqual(3, sample.Count);

            sample.Clear();

            Assert.AreEqual(0, sample.Count);
        }
예제 #35
0
		public void Dispose()
		{
			stack.Pop();
			Lazies = null;
			IDs = null;
			Objs = null;
			refHandlers = null;
		}
        public void TryGetValueWorksFine()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 }
            };

            IList<object> value;
            Assert.IsTrue(sample.TryGetValue("key1", out value));
            Assert.AreEqual("value1", value[0]);

            Assert.IsTrue(sample.TryGetValue("key2", out value));
            Assert.AreEqual("value2", value[0]);

            Assert.IsTrue(sample.TryGetValue("key3", out value));
            Assert.AreEqual(33, value[0]);

            Assert.IsFalse(sample.TryGetValue("key4", out value));
            Assert.IsNull(value);
        }
        public void AddingListValueMergesWithExistingValues()
        {
            var sample = new DictionaryList<string, object>
            {
                {"key1", "value1"},
                {"key2", "value2"},
                {"key3", 33},
                {"key2", new List<object> { 22 }},
                {"key1", "value12"}
            };

            Assert.AreEqual("value1", sample["key1"][0]);
            Assert.AreEqual("value12", sample["key1"][1]);

            Assert.AreEqual("value2", sample["key2"][0]);
            Assert.AreEqual(22, sample["key2"][1]);

            Assert.AreEqual(33, sample["key3"][0]);
        }
        public void AddsRangeOfValues()
        {
            var target = new DictionaryList<string, object>
            {
                { "key1", 11 }
            };

            var source  = new DictionaryList<string, object>
            {
                { "key1", 111 },
                { "key2", 22 },
                { "key2", 222 },
                { "key3", "3" }
            };

            target.AddRange(source);

            Assert.AreEqual(3, target.Count);
            Assert.AreEqual(2, target["key1"].Count);
            Assert.AreEqual(11, target["key1"][0]);
            Assert.AreEqual(111, target["key1"][1]);
            Assert.AreEqual(2, target["key2"].Count);
            Assert.AreEqual(22, target["key2"][0]);
            Assert.AreEqual(222, target["key2"][1]);
            Assert.AreEqual(1, target["key3"].Count);
            Assert.AreEqual("3", target["key3"][0]);
        }
        public void CanAddNullValueList()
        {
            // ReSharper disable RedundantCast
            var sample = new DictionaryList<string, object>
            {
                { "key1", (IList<object>)null }
            };

            Assert.AreEqual(0, sample["key1"].Count);

            sample.Add("key1", (IList<object>)null);

            Assert.AreEqual(0, sample["key1"].Count);
            // ReSharper restore RedundantCast
        }
        public void CanAddSingleNullValues()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", (object)null }
            };

            Assert.IsNull(sample["key1"][0]);
        }
        public void EnumeratesThroughAllElementsWithExplicitEnumerator()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 },
                { "key1", 44 }
            };

            var iterator = ((IEnumerable)sample).GetEnumerator();

            VerifyEnumerator((IEnumerator<KeyValuePair<string, IList<object>>>)iterator);
        }
        public void EnumeratesThroughAllElements()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 },
                { "key1", 44 }
            };

            var iterator = sample.GetEnumerator();
            VerifyEnumerator(iterator);

            iterator.Reset();
            VerifyEnumerator(iterator);
        }
        public void CtorWithCapacityAndOrdinalIgnoreCaseComparerCorrectlyInitializesDictionary()
        {
            var sample = new DictionaryList<string, object>(100, StringComparer.OrdinalIgnoreCase)
            {
                { "key1", "value1" }, 
                { "key2", "value2" }, 
                { "key3", 33 }
            };

            Assert.AreEqual(3, sample.Count);

            Assert.IsTrue(sample.ContainsKey("key1"));
            Assert.IsTrue(sample.ContainsKey("key2"));
            Assert.IsTrue(sample.ContainsKey("key3"));

            Assert.IsTrue(sample.ContainsKey("KEY1"));
            Assert.IsTrue(sample.ContainsKey("KEy2"));
            Assert.IsTrue(sample.ContainsKey("kEY3"));
        }
        public void CtorWithCapacityCorrectlyInitializesDictionary()
        {
            var sample = new DictionaryList<string, object>(100)
            {
                { "key1", "value1" }, 
                { "key2", "value2" }, 
                { "key3", 33 }
            };

            Assert.AreEqual(3, sample.Count);

            Assert.IsTrue(sample.ContainsKey("key1"));
            Assert.IsTrue(sample.ContainsKey("key2"));
            Assert.IsTrue(sample.ContainsKey("key3"));

            Assert.IsFalse(sample.ContainsKey("KEY1"));
            Assert.IsFalse(sample.ContainsKey("KEy2"));
            Assert.IsFalse(sample.ContainsKey("kEY3"));
        }
예제 #45
0
        private SortedList<int, Notice[]> PrepareSortedQueue()
        {
            DictionaryList<int, Notice> dl = new DictionaryList<int, Notice>();
            List<NabfAgent> agents;
            SortedList<int, NabfAgent> topDesires;
            int lowestDesire;

            foreach (Notice n in _availableJobs.SelectMany(kvp => kvp.Value))
            {
                lowestDesire = FindTopDesiresForNotice(n, out topDesires, out agents);
                if (lowestDesire != -1)
                {
                    n.HighestAverageDesirabilityForNotice = topDesires.Keys.Sum() / topDesires.Keys.Count;
                    dl.Add(n.HighestAverageDesirabilityForNotice, n);
                    n.AddRangeToTopDesireAgents(agents);
                }
            }
            SortedList<int, Notice[]> jobs = new SortedList<int, Notice[]>(new InvertedComparer<int>());

            foreach (KeyValuePair<int, Notice[]> kvp in dl)
                jobs.Add(kvp.Key, kvp.Value);

            return jobs;
        }
        public void CtorCopiesItemsFromAnotherDictionary()
        {
            var sample = new DictionaryList<string, object>(new Dictionary<string, IList<object>>
            {
                { "key1", new List<object>{ "value1"} }, 
                { "key2", new List<object>{ "value2"} }, 
                { "key3", new List<object>{ 33 } }
            });

            Assert.AreEqual(3, sample.Count);

            Assert.IsTrue(sample.ContainsKey("key1"));
            Assert.IsTrue(sample.ContainsKey("key2"));
            Assert.IsTrue(sample.ContainsKey("key3"));

            Assert.IsFalse(sample.ContainsKey("KEY1"));
            Assert.IsFalse(sample.ContainsKey("KEy2"));
            Assert.IsFalse(sample.ContainsKey("kEY3"));
        }
        public void CtorOrdinalIgnoreCaseComparerCopiesItemsFromAnotherDictionaryList()
        {
            var sample = new DictionaryList<string, object>(new DictionaryList<string, object>
            {
                { "key1", new List<object> { "value1"} }, 
                { "key2", new List<object> { "value2"} }, 
                { "key3", new List<object> { 33} }
            }, StringComparer.OrdinalIgnoreCase);

            Assert.AreEqual(3, sample.Count);

            Assert.IsTrue(sample.ContainsKey("key1"));
            Assert.IsTrue(sample.ContainsKey("key2"));
            Assert.IsTrue(sample.ContainsKey("key3"));

            Assert.IsTrue(sample.ContainsKey("KEY1"));
            Assert.IsTrue(sample.ContainsKey("KEy2"));
            Assert.IsTrue(sample.ContainsKey("kEY3"));
        }
        public void TestContains()
        {
            var newList = new List<string>()
                {
                    "A", "B", "C", "D",
                };

            var dictList = new DictionaryList<string>(newList);

            Assert.AreEqual(4, dictList.Count);

            Assert.IsTrue(dictList.Contains("A"));
            Assert.IsFalse(dictList.Contains("a"));

            Assert.IsTrue(dictList.Contains("B"));
            Assert.IsFalse(dictList.Contains("b"));

            Assert.IsTrue(dictList.Contains("C"));
            Assert.IsFalse(dictList.Contains("c"));

            Assert.IsTrue(dictList.Contains("D"));
            Assert.IsFalse(dictList.Contains("d"));
        }
        public void ListsAllKeys()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 },
                { "key1", 44 }
            };

            var keys = sample.Keys;

            Assert.AreEqual(3, keys.Count);
            Assert.AreEqual("key1", keys.ElementAt(0));
            Assert.AreEqual("key2", keys.ElementAt(1));
            Assert.AreEqual("key3", keys.ElementAt(2));
        }
        public void TestRemove()
        {
            var newList = new List<string>()
                {
                    "A", "B", "C", "D",
                };

            var dictList = new DictionaryList<string>(newList);

            Assert.AreEqual(4, dictList.Count);
            Assert.AreEqual("A", dictList[0]);
            Assert.AreEqual("B", dictList[1]);
            Assert.AreEqual("C", dictList[2]);
            Assert.AreEqual("D", dictList[3]);

            Assert.IsTrue(dictList.Remove("B"));
            Assert.AreEqual(3, dictList.Count);
            Assert.AreEqual("A", dictList[0]);
            Assert.AreEqual("C", dictList[1]);
            Assert.AreEqual("D", dictList[2]);

            Assert.IsFalse(dictList.Remove("a"));
            Assert.AreEqual(3, dictList.Count);
            Assert.AreEqual("A", dictList[0]);
            Assert.AreEqual("C", dictList[1]);
            Assert.AreEqual("D", dictList[2]);
        }
예제 #51
0
 private void InitPolymorphicClassDescriptorsList(Int32 size)
 {
     if (polymorphClassDescriptors == null)
     {
         polymorphClassDescriptors = new DictionaryList<String, ClassDescriptor>(size);
     }
     if (polymorphClasses == null)
     {
         polymorphClasses = new Dictionary<String, Type>(size);
     }
     if (tlvClassDescriptors == null)
     {
         tlvClassDescriptors = new Dictionary<Int32, ClassDescriptor>(size);
     }
 }
        public void TestClear()
        {
            var newList = new List<string>()
                {
                    "A", "B", "C", "D",
                };

            var dictList = new DictionaryList<string>(newList);

            Assert.AreEqual(4, dictList.Count);
            Assert.AreEqual("A", dictList[0]);
            Assert.AreEqual("B", dictList[1]);
            Assert.AreEqual("C", dictList[2]);
            Assert.AreEqual("D", dictList[3]);

            dictList.Clear();

            Assert.AreEqual(0, dictList.Count);
        }
        public void AddFromICollectionCountAndContainsAndThisGetWorkingFine()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", new List<object> { "value1" } },
                { "key2", new List<object> { "value2" } },
                { "key3", new List<object> { 33 } }
            };

            Assert.AreEqual(3, sample.Count);

            var value = sample["key1"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<string>(value[0]);
            Assert.AreEqual("value1", value[0]);

            value = sample["key2"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<string>(value[0]);
            Assert.AreEqual("value2", value[0]);

            value = sample["key3"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<int>(value[0]);
            Assert.AreEqual(33, value[0]);


            sample.Add("key1", 44);

            Assert.AreEqual(3, sample.Count);

            value = sample["key1"];
            Assert.IsInstanceOf<List<object>>(value);
            Assert.AreEqual(2, value.Count);
            Assert.IsInstanceOf<string>(value[0]);
            Assert.AreEqual("value1", value[0]);
            Assert.IsInstanceOf<int>(value[1]);
            Assert.AreEqual(44, value[1]);

            value = sample["key2"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<string>(value[0]);
            Assert.AreEqual("value2", value[0]);

            value = sample["key3"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<int>(value[0]);
            Assert.AreEqual(33, value[0]);



            sample.Remove("key2");

            Assert.AreEqual(2, sample.Count);

            value = sample["key1"];
            Assert.AreEqual(2, value.Count);
            Assert.IsInstanceOf<string>(value[0]);
            Assert.AreEqual("value1", value[0]);
            Assert.IsInstanceOf<int>(value[1]);
            Assert.AreEqual(44, value[1]);

            value = sample["key3"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<int>(value[0]);
            Assert.AreEqual(33, value[0]);


            Assert.IsFalse(sample.Remove("key2"));

            sample.Remove("key1");

            Assert.AreEqual(1, sample.Count);

            value = sample["key3"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<int>(value[0]);
            Assert.AreEqual(33, value[0]);

            sample.Remove("key3");

            Assert.AreEqual(0, sample.Count);
        }
        public void AddingNullRangeDoesNothing()
        {
            var target = new DictionaryList<string, object>
            {
                { "key1", 11 }
            };

            target.AddRange(null);

            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(1, target["key1"].Count);
            Assert.AreEqual(11, target["key1"][0]);
        }
예제 #55
0
        void BackupProgramHandler_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Core.settings.IsBackupPathSet || archive_name_override != null) {
                if (archive_name_override != null)
                    output_path = Path.GetDirectoryName(archive_name_override);
                else
                    output_path = Core.settings.backup_path;

                IList<GameEntry> games;

                if (back_these_up != null && back_these_up.Count > 0) {
                    games = back_these_up;
                } else {
                    if (Games.detected_games_count == 0)
                        Games.detectGames();
                    games = Games.DetectedGames.Items;
                }

                if (games.Count > 0) {
                    ProgressHandler.value = 1;
                    ProgressHandler.max = games.Count;
                    TranslatingProgressHandler.setTranslatedMessage("GamesToBeBackedUpCount", games.Count.ToString());

                    foreach (GameEntry game in games) {
                        if (CancellationPending)
                            return;

                        //if(archive_name_override!=null)
                        //all_users_archive = new ArchiveHandler(new FileInfo(archive_name_override),game.id);

                        if (games.Count == 1) {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpSingleGame", game.Title);
                        } else {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpMultipleGames", game.Title, ProgressHandler.value.ToString(), games.Count.ToString());
                        }

                        List<DetectedFile> files;
                        if (only_these_files != null && only_these_files.Count > 0) {
                            files = only_these_files;
                        } else {
                            files = game.Saves.Flatten();
                            ;
                        }

                        Archive override_archive = null;

                        try {
                            DictionaryList<Archive, DetectedFile> backup_files = new DictionaryList<Archive, DetectedFile>();
                            foreach (DetectedFile file in files) {
                                ArchiveID archive_id;
                                Archive archive;
                                if (CancellationPending)
                                    return;

                                archive_id = new ArchiveID(game.id, file);

                                if (archive_name_override != null) {
                                    if (override_archive == null)
                                        file.Type = null;
                                        override_archive = new Archive(new FileInfo(archive_name_override), new ArchiveID(game.id, file));
                                    archive = override_archive;
                                } else {
                                    if (Archives.Get(archive_id) == null) {
                                        Archives.Add(new Archive(output_path, new ArchiveID(game.id, file)));
                                    }
                                    archive = Archives.Get(archive_id);
                                }

                                backup_files.Add(archive, file);
                            }
                            if (CancellationPending)
                                return;

                            foreach (KeyValuePair<Archive, List<DetectedFile>> backup_file in backup_files) {
                                if (override_archive == null)
                                    backup_file.Key.backup(backup_file.Value, false,false);
                                else
                                    backup_file.Key.backup(backup_file.Value, true, false);
                            }

                        } catch (Exception ex) {
                            TranslatingMessageHandler.SendException(ex);
                        } finally {
                            ProgressHandler.value++;
                        }
                    }
                } else {
                    TranslatingMessageHandler.SendError("NothingToBackup");
                }
            } else {
                TranslatingMessageHandler.SendError("BackupPathNotSet");
            }
        }
예제 #56
0
 private void InitTagClassDescriptorsArrayList(int initialSize)
 {
     if (polymorphClassDescriptors == null)
     {
         polymorphClassDescriptors = new DictionaryList<string, ClassDescriptor>(initialSize);
     }
     if (polymorphClasses == null)
     {
         polymorphClasses = new Dictionary<String, Type>(initialSize);
     }
 }
        public void IndexerWorksFine()
        {
            var sample = new DictionaryList<string, object>
            {
                { "key1", "value1" },
                { "key2", "value2" },
                { "key3", 33 }
            };

            Assert.AreEqual("value1", sample["key1"][0]);
            Assert.AreEqual("value2", sample["key2"][0]);
            Assert.AreEqual(33, sample["key3"][0]);

            sample["key1"] = new List<object> { 23 };

            var value = sample["key1"];
            Assert.AreEqual(1, value.Count);
            Assert.IsInstanceOf<int>(value[0]);
            Assert.AreEqual(23, value[0]);

            Assert.AreEqual("value2", sample["key2"][0]);
            Assert.AreEqual(33, sample["key3"][0]);
        }
예제 #58
0
 public void Dispose()
 {
     //Если ссылочный объект не был клонирован, то ссылки переделываются на оригинал
     foreach (var lazy in Lazies)
         foreach (var action in lazy)
             action(lazy.Key);
     Lazies = null;
     Objs = null;
     CloneScope cs;
     do
     {
         cs = stack.Pop();
         if (cs != this)
             cs.Dispose();
         else
             break;
     } while (stack.Count > 0);
 }
        /**
         * bind metadata field descriptors to sub-fields of this nested field, with field names as keys,
         * but without mixins field.
         * <p>
         * sub-fields that lack corresponding field descriptors will be removed from this nested field.
         * <p>
         * note that this field no longer uses a boolean flag to prevent multiple invocation. this should
         * have been done by the bindClassDescriptor() method.
         *
         * @param metadataTScope
         *          the translation scope of (generated) metadata classes.
         * @param metadataClassDescriptor
         *          the metadata class descriptor where field descriptors can be found.
         */
        protected void BindMetadataFieldDescriptors(SimplTypesScope metadataTScope,
            MetadataClassDescriptor metadataClassDescriptorToBind)
        {
            bool needCloneKids = false;

            // check if the class's base class is genereic typed, and make sure itself is not generic.
            MetadataClassDescriptor metadataCd = MetadataClassDescriptor;
            MetaMetadata baseMmd = TypeMmd;
            while(baseMmd != null && metadataCd != null)
            {
                if (metadataCd.GetGenericTypeVars().Count == 0 && baseMmd.GenericTypeVars != null)
                {
                    needCloneKids = true;
                    break;
                }
                metadataCd = baseMmd.MetadataClassDescriptor;
                baseMmd = baseMmd.TypeMmd;
            }

            if (needCloneKids)
            {
                DictionaryList<string, MetaMetadataField> clonedKids = new DictionaryList<string, MetaMetadataField>();
                foreach (KeyValuePair<string, MetaMetadataField> entry in Kids)
                {
                    string key = entry.Key;
                    MetaMetadataField field = entry.Value;

                    // look up to see if the field is declared in a generic typed class. If not, it does not need to clone it.
                    MetaMetadata declaringMmd = field.DeclaringMmd;
                    if (declaringMmd != null && declaringMmd.GenericTypeVars != null && declaringMmd.IsGenericMetadata)
                    {
                        // clone the field
                        field = field.Clone();
                        // remove the inherited field descriptor
                        field.MetadataFieldDescriptor = null;
                    }
                    clonedKids.Put(key, field);
                }
                Kids = clonedKids;
            }

            // copy the kids collection first to prevent modification to the collection during iteration (which may invalidate the iterator).
            List<MetaMetadataField> fields = new List<MetaMetadataField>(Kids.Values);

            foreach (MetaMetadataField thatChild in fields)
            {
                // look up by field name and bind
                MetadataFieldDescriptor metadataFd = thatChild.BindMetadataFieldDescriptor(metadataTScope, metadataClassDescriptorToBind);
                if (metadataFd == null)
                {
                    Debug.WriteLine("Cannot bind metadata field descriptor for " + thatChild);
                    Kids.Remove(thatChild.Name);
                    continue;
                }

                // set defininig mmdfield

                // process hide and shadows
                var isImage = thatChild is MetaMetadataCompositeField && "image".Equals(((MetaMetadataCompositeField) thatChild).Type);
                HashSet<String> nonDisplayedFieldNames = NonDisplayedFieldNames;
                if (thatChild.Hide && !isImage)
                    nonDisplayedFieldNames.Add(thatChild.Name);
                if (thatChild.Shadows != null)
                    nonDisplayedFieldNames.Add(thatChild.Shadows);

                // recursively process sub-fields
                Int32 fieldType = metadataFd.FdType;
                if (fieldType == FieldTypes.CompositeElement || fieldType == FieldTypes.CollectionElement)
                {
                    // bind class descriptor for nested sub-fields
                    MetaMetadataNestedField nested = (MetaMetadataNestedField) thatChild;
                    MetadataFieldDescriptor fd = nested.MetadataFieldDescriptor;
                    if (fd.IsPolymorphic)
                    {
                        Debug.WriteLine("Polymorphic field: " + nested + ", not binding an element class descriptor.");
                    }
                    else
                    {
                        MetadataClassDescriptor elementClassDescriptor =
                            ((MetaMetadataNestedField) thatChild).BindMetadataClassDescriptor(metadataTScope);
                        if (elementClassDescriptor != null)
                        {
                            MetaMetadata mmdForThatChild = nested.TypeMmd;
                            if (mmdForThatChild != null && mmdForThatChild.MetadataClassDescriptor == null)
                                //							mmdForThatChild.setMetadataClassDescriptor(elementClassDescriptor);
                                mmdForThatChild.BindMetadataClassDescriptor(metadataTScope);
                        }
                        else
                        {
                            Debug.WriteLine("Cannot determine elementClassDescriptor for " + thatChild);
                            Kids.Remove(thatChild.Name);
                        }
                    }
                }

                if (this is MetaMetadata)
                {
                    MetaMetadata mmd = (MetaMetadata) this;
                    String naturalId = thatChild.AsNaturalId;
                    if (naturalId != null)
                    {
                        mmd.NaturalIds.Put(naturalId, thatChild);
                    }
                }
            }
        }