Beispiel #1
0
		/// <summary>
		/// Finds the structure type corresponding to a group tag.
		/// </summary>
		/// <param name="group">The group name or group tag of the tag definition.</param>
		/// <returns>The structure type if found, or <c>null</c> otherwise.</returns>
		public static Type Find(string group)
		{
			foreach (var entry in Types)
			{
				var type = entry.Value;
				var attribute = TagStructure.GetTagStructureAttribute(type);
				if (attribute.Name == group)
					return type;
			}

			return Find(new Tag(group));
		}
Beispiel #2
0
        /// <summary>
        /// Checks to see if a tag definition exists.
        /// </summary>
        /// <param name="group">The group name or group tag of the tag definition.</param>
        /// <returns>true if the tag definition exists.</returns>
        public static bool Exists(string group)
        {
            foreach (var entry in Types)
            {
                var type      = entry.Value;
                var attribute = TagStructure.GetTagStructureAttribute(type);

                if (attribute.Name == group)
                {
                    return(true);
                }
            }

            return(Exists(new Tag(group)));
        }
Beispiel #3
0
        public static bool TryFind(string group, out Type result)
        {
            foreach (var entry in Types)
            {
                var type      = entry.Value;
                var attribute = TagStructure.GetTagStructureAttribute(type);

                if (attribute.Name == group)
                {
                    result = type;
                    return(true);
                }
            }

            return(TryFind(new Tag(group), out result));
        }
        private void Analyze(Type mainType, CacheVersion version)
        {
            // Get the attribute for the main structure type
            Structure = TagStructure.GetTagStructureAttribute(mainType, version);
            if (Structure == null)
            {
                throw new InvalidOperationException($"No `{nameof(TagStructureAttribute)}` for `{version.ToString()}` found on `{mainType.Name}`.");
            }

            // Scan through the type's inheritance hierarchy and analyze each TagStructure attribute
            var currentType = mainType;

            Types = new List <Type>();
            while (currentType != null)
            {
                var attrib = (currentType != mainType) ? TagStructure.GetTagStructureAttribute(currentType, version) : Structure;
                if (attrib != null)
                {
                    Types.Add(currentType);
                    TotalSize += attrib.Size;
                    if (attrib.Tag != null)
                    {
                        if (GroupTag.Value == -1)
                        {
                            GroupTag = new Tag(attrib.Tag);
                        }
                        else if (ParentGroupTag.Value == -1)
                        {
                            ParentGroupTag = new Tag(attrib.Tag);
                        }
                        else if (GrandparentGroupTag.Value == -1)
                        {
                            GrandparentGroupTag = new Tag(attrib.Tag);
                        }
                    }
                }
                currentType = currentType.BaseType;
            }
        }
Beispiel #5
0
        public static Tag GetGroupTag <T>()
        {
            var attribute = TagStructure.GetTagStructureAttribute(typeof(T));

            return(new Tag(attribute.Tag));
        }