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);
}
}