using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
namespace Svg
{
///
/// Provides the methods required in order to parse and create instances from XML.
///
internal class SvgElementFactory
{
private static List availableElements;
///
/// Gets a list of available types that can be used when creating an .
///
private static List AvailableElements
{
get
{
if (availableElements == null)
{
var svgTypes = from t in typeof(SvgDocument).Assembly.GetExportedTypes()
where t.GetCustomAttributes(typeof(SvgElementAttribute), true).Length > 0
&& t.IsSubclassOf(typeof(SvgElement))
select new ElementInfo { ElementName = ((SvgElementAttribute)t.GetCustomAttributes(typeof(SvgElementAttribute), true)[0]).ElementName, ElementType = t };
availableElements = svgTypes.ToList();
}
return availableElements;
}
}
///
/// Creates an from the current node in the specified .
///
/// The containing the node to parse into an .
/// The parameter cannot be null.
/// The CreateDocument method can only be used to parse root <svg> elements.
public static SvgDocument CreateDocument(XmlTextReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
if (reader.LocalName != "svg")
{
throw new InvalidOperationException("The CreateDocument method can only be used to parse root