示例#1
0
        /// <summary>
        ///     Gets the list of a specified type.
        ///     May create a new one.
        /// </summary>
        /// <param name="specType">The type to get the list of</param>
        /// <returns>A list</returns>
        protected TypeList GetTypeList <TSub>() where TSub : class, TBase
        {
            Type thisType = typeof(TSub);

            if (!this.typeDict.ContainsKey(thisType))
            {
                TypeList typeList = TypeList.New <TSub>();

                foreach (KeyValuePair <Type, TypeList> item in this.typeDict)
                {
                    TypeList otherList = item.Value;

                    if (otherList.Type.IsSubclassOf(thisType))
                    {
                        typeList.Subs.Add(otherList.Main);
                    }
                    else if (thisType.IsSubclassOf(otherList.Type))
                    {
                        otherList.Subs.Add(typeList.Main);
                    }
                }

                this.storage.Add(typeList.Main);
                this.typeDict.Add(thisType, typeList);

                return(typeList);
            }

            return(this.typeDict[thisType]);
        }