Ejemplo n.º 1
0
        /// <summary>
        /// Returns the MetaType for the specified Type.
        /// </summary>
        /// <param name="type">The Type to provide the MetaType for.</param>
        /// <returns>The constructed MetaType.</returns>
        public static MetaType GetMetaType(Type type)
        {
            Debug.Assert(!TypeUtility.IsPredefinedType(type), "Should never attempt to create a MetaType for a base type.");

            MetaType metaType = null;

            if (!MetaTypes.TryGetValue(type, out metaType))
            {
                metaType        = new MetaType(type);
                MetaTypes[type] = metaType;
            }
            return(metaType);
        }
Ejemplo n.º 2
0
        /// <summary>Returns a list of meta variations of a specific item</summary>
        /// <param name="typeId">The type ID to get the variations of</param>
        /// <returns>A List(Of Integer) containing the typeIDs of the variations</returns>
        public static List <int> GetVariationsForItem(int typeId)
        {
            // Fetch the parent item ID for this item
            int      parentTypeId = typeId;
            MetaType metaType;

            if (MetaTypes.TryGetValue(typeId, out metaType))
            {
                parentTypeId = metaType.ParentId;
            }

            // Fetch all items with this same parent ID
            List <int> itemIDs = (from mt in MetaTypes.Values where mt.ParentId == parentTypeId select mt.Id).ToList();

            // Add the current item if it is the parent item
            if (itemIDs.Contains(parentTypeId) == false)
            {
                itemIDs.Add(parentTypeId);
            }

            return(itemIDs);
        }