Exemple #1
0
 /// <summary>
 /// Set the value of an attribute, with the value being a enum instance.
 /// The enum in question should have an entry with int value -1, which
 /// corresponds to no attribute.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 protected void SetEnumAttr(string name, object value)
 {
     if ((value == null) || ((int)value == -1))
     {
         RemoveAttribute(name);
         return;
     }
     SetAttribute(name, EnumParser.ToString(value));
 }
Exemple #2
0
        /// <summary>
        /// Get the value of an attribute, as a value in the given Enum type.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="enumType"></param>
        /// <returns></returns>
        protected object GetEnumAttr(string name, Type enumType)
        {
            string a = this.GetAttribute(name);

            return(EnumParser.Parse(a, enumType));
        }
Exemple #3
0
        /// <summary>
        /// Get the value of an attribute, as a value in the given Enum type.
        /// The specified enum should have a member with value -1, which will
        /// be returned if the attribute doesn't exist or is in the wrong format.
        /// </summary>
        /// <typeparam name="T">The enum type</typeparam>
        /// <param name="name">The attribute name</param>
        /// <returns>The enum value</returns>
        protected T GetEnumAttr <T>(string name)
        {
            string a = this.GetAttribute(name);

            return(EnumParser.Parse <T>(a));
        }