GetTagType() public static method

Returns the type of the specified tag (its identifier). This method is used by the Type property.
public static GetTagType ( Type tag ) : string
tag System.Type
return string
Exemplo n.º 1
0
        /// <summary>
        /// Retrurns the tag instance from its type and value.
        /// </summary>
        protected TagBase GetTagFromType(string type, string value, bool hasContents)
        {
            foreach (Type myTagType in Tags)
            {
                string myType = TagBase.GetTagType(myTagType);
                if (string.Compare(myType, type, true) == 0)
                {
                    TagBase myTag = Activator.CreateInstance(myTagType) as TagBase;
                    myTag.InitializeFromData(this, value, hasContents);
                    return(myTag);
                }
            }

            throw new Exception(string.Format("Tag cannot be found: {0}", type));
        }