Commit df86976f authored by Tebjan Halm's avatar Tebjan Halm
Browse files

big performance improvement (over 50%) for writing svg strings

parent 84b71ceb
...@@ -70,13 +70,7 @@ ...@@ -70,13 +70,7 @@
<DocumentationFile>bin\Release\Svg.XML</DocumentationFile> <DocumentationFile>bin\Release\Svg.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.JScript" />
<Reference Include="Microsoft.Vsa" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
......
...@@ -15,6 +15,15 @@ namespace Svg ...@@ -15,6 +15,15 @@ namespace Svg
/// </summary> /// </summary>
public abstract class SvgElement : ISvgElement, ISvgTransformable, ICloneable public abstract class SvgElement : ISvgElement, ISvgTransformable, ICloneable
{ {
//optimization
protected class AttributeTuple
{
public PropertyDescriptor Property;
public SvgAttributeAttribute Attribute;
}
protected IEnumerable<AttributeTuple> _svgAttributes;
internal SvgElement _parent; internal SvgElement _parent;
private string _elementName; private string _elementName;
private SvgAttributeCollection _attributes; private SvgAttributeCollection _attributes;
...@@ -283,6 +292,12 @@ namespace Svg ...@@ -283,6 +292,12 @@ namespace Svg
this._eventHandlers = new EventHandlerList(); this._eventHandlers = new EventHandlerList();
this._elementName = string.Empty; this._elementName = string.Empty;
this._customAttributes = new Dictionary<string, string>(); this._customAttributes = new Dictionary<string, string>();
//fill svg attribute description
_svgAttributes = from PropertyDescriptor a in TypeDescriptor.GetProperties(this)
let attribute = a.Attributes[typeof(SvgAttributeAttribute)] as SvgAttributeAttribute
where attribute != null
select new AttributeTuple { Property = a, Attribute = attribute };
} }
...@@ -336,12 +351,7 @@ namespace Svg ...@@ -336,12 +351,7 @@ namespace Svg
protected virtual void WriteAttributes(XmlTextWriter writer) protected virtual void WriteAttributes(XmlTextWriter writer)
{ {
var attributes = from PropertyDescriptor a in TypeDescriptor.GetProperties(this) foreach (var attr in _svgAttributes)
let attribute = a.Attributes[typeof(SvgAttributeAttribute)] as SvgAttributeAttribute
where attribute != null
select new { Property = a, Attribute = attribute };
foreach (var attr in attributes)
{ {
if (attr.Property.Converter.CanConvertTo(typeof(string))) if (attr.Property.Converter.CanConvertTo(typeof(string)))
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment