Browse Source

Use static PerspexParserFactory.

Improves startup times on XamlTestApplication from about 9.4 to 2.6
seconds.
pull/413/head
Steven Kirk 10 years ago
parent
commit
1ac9c50568
  1. 14
      src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs

14
src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs

@ -19,11 +19,13 @@ namespace Perspex.Markup.Xaml
/// </summary> /// </summary>
public class PerspexXamlLoader : XmlLoader public class PerspexXamlLoader : XmlLoader
{ {
private static PerspexParserFactory s_parserFactory;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PerspexXamlLoader"/> class. /// Initializes a new instance of the <see cref="PerspexXamlLoader"/> class.
/// </summary> /// </summary>
public PerspexXamlLoader() public PerspexXamlLoader()
: this(new PerspexParserFactory()) : this(GetParserFactory())
{ {
} }
@ -126,6 +128,16 @@ namespace Perspex.Markup.Xaml
} }
} }
private static PerspexParserFactory GetParserFactory()
{
if (s_parserFactory == null)
{
s_parserFactory = new PerspexParserFactory();
}
return s_parserFactory;
}
/// <summary> /// <summary>
/// Gets the URI for a type. /// Gets the URI for a type.
/// </summary> /// </summary>

Loading…
Cancel
Save