Svg.SvgDefaults.IsDefault C# (CSharp) Method

IsDefault() public static method

Checks whether the property value is the default value of the svg definition.
public static IsDefault ( string attributeName, string value ) : bool
attributeName string Name of the svg attribute
value string
return bool
        public static bool IsDefault(string attributeName, string value)
        {
            if (_defaults.ContainsKey(attributeName))
            {
                if (_defaults[attributeName] == value) return true;
            }
            return false;
        }
    }

Usage Example

Esempio n. 1
0
        protected virtual void WriteAttributes(XmlTextWriter writer)
        {
            foreach (var attr in _svgAttributes)
            {
                if (attr.Property.Converter.CanConvertTo(typeof(string)))
                {
                    object propertyValue = attr.Property.GetValue(this);

                    var forceWrite = false;
                    if ((attr.Attribute.Name == "fill") && (Parent != null))
                    {
                        object parentValue;
                        if (TryResolveParentAttributeValue(attr.Attribute.Name, out parentValue))
                        {
                            if ((parentValue == propertyValue) ||
                                ((parentValue != null) && parentValue.Equals(propertyValue)))
                            {
                                continue;
                            }

                            forceWrite = true;
                        }
                    }

                    if (propertyValue != null)
                    {
                        var    type  = propertyValue.GetType();
                        string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));

                        if (!SvgDefaults.IsDefault(attr.Attribute.Name, value) || forceWrite)
                        {
                            writer.WriteAttributeString(attr.Attribute.NamespaceAndName, value);
                        }
                    }
                    else if (attr.Attribute.Name == "fill") //if fill equals null, write 'none'
                    {
                        string value = (string)attr.Property.Converter.ConvertTo(propertyValue, typeof(string));
                        writer.WriteAttributeString(attr.Attribute.NamespaceAndName, value);
                    }
                }
            }

            //add the custom attributes
            foreach (var item in this._customAttributes)
            {
                writer.WriteAttributeString(item.Key, item.Value);
            }
        }
All Usage Examples Of Svg.SvgDefaults::IsDefault