Exemplo n.º 1
0
        public IStyleProperty SetStyleProperty <T>(string name, T enumValue)
            where T : struct, IConvertible
        {
            if (String.IsNullOrEmpty(name) || !typeof(T).IsEnum)
            {
                return(null);
            }

            StyleEnumProperty <T> property = null;

            if (Contains(name))
            {
                property = _styleProperties[name] as StyleEnumProperty <T>;
                if (property != null && !property.EnumValue.Equals(enumValue))
                {
                    property.EnumValue = enumValue;
                }
            }

            if (property == null)
            {
                property = new StyleEnumProperty <T>(name, enumValue);
                _styleProperties[name] = property;
            }

            return(property);
        }
Exemplo n.º 2
0
        protected bool LoadStyleEnumProperty <T>(XmlElement parentElement, string propertyName)
            where T : struct, IConvertible
        {
            XmlElement propertyElement = parentElement[propertyName];

            if (propertyElement != null)
            {
                string value = null;
                if (LoadStringFromChildElementInnerText("Value", propertyElement, ref value))
                {
                    StyleEnumProperty <T> property = new StyleEnumProperty <T>(propertyName, default(T));
                    if (property.SetStringValue(value))
                    {
                        SetStyleProperty(property);
                        return(true);
                    }
                }
            }

            return(false);
        }