Class XFactory
Factory class for generating objects from XML elements using registered generator functions.
public static class XFactory
- Inheritance
-
XFactory
- Inherited Members
Remarks
Generator functions must be added to Regs to enable the factory to create objects from XML.
Properties
Regs
Gets or sets the dictionary mapping XML element names to generator functions with relative file path.
public static Dictionary<string, XFactory.GenByXElementDelegate> Regs { get; set; }
Property Value
Methods
GenByChild<T>(XElement, string, IProgress<object>, bool, object[])
Generates an object of type T from the first child element of the provided XML element. This overload discards the relative file path output.
public static T GenByChild<T>(XElement src, string baseDirectory, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class
Parameters
Returns
- T
Type Parameters
T
GenByChild<T>(XElement, string, out string, IProgress<object>, bool, object[])
Generates an object of type T from the first child element of the provided XML element.
public static T GenByChild<T>(XElement src, string baseDirectory, out string relFile, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class
Parameters
srcXElementThe parent XML element containing the child to process
baseDirectorystringThe base directory for resolving paths
relFilestringOutput parameter that receives the relative file path if src is a file reference, or null otherwise
progressIProgress<object>Progress reporter for the XML parsing chain
enableRebaseboolWhether to rebase the directory to the file's location
resobject[]Additional parameters for generation
Returns
- T
The generated object of type T, or null if src is null
Type Parameters
TThe type of object to generate
GenByFile<T>(string, string, IProgress<object>, bool, object[])
Generates an object of type T from an XML file.
public static T GenByFile<T>(string baseDirectory, string relFile, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class
Parameters
baseDirectorystringThe base directory for resolving paths
relFilestringThe relative file path to the XML file
progressIProgress<object>Progress reporter for the XML parsing chain
enableRebaseboolWhether to rebase the directory to the file's location
resobject[]Additional parameters for generation
Returns
- T
The generated object of type T, or null if relFile is null
Type Parameters
TThe type of object to generate
GenFileRefSourceByChild<T>(XElement, string, IProgress<object>, bool, object[])
Generates a FileRefSource<T> from the first child element of the provided XML element.
public static FileRefSource<T> GenFileRefSourceByChild<T>(XElement src, string baseDirectory, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class, IMakeXmlSource
Parameters
Returns
Type Parameters
T
GenFileRefSourceByFile<T>(string, string, IProgress<object>, bool, object[])
Generates a FileRefSource<T> from an XML file.
public static FileRefSource<T> GenFileRefSourceByFile<T>(string baseDirectory, string relFile, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class, IMakeXmlSource
Parameters
Returns
Type Parameters
T
GenFileRefSource<T>(XElement, string, IProgress<object>, bool, object[])
Generates a FileRefSource<T> from an XML element.
public static FileRefSource<T> GenFileRefSource<T>(XElement src, string baseDirectory, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class, IMakeXmlSource
Parameters
Returns
Type Parameters
T
Gen<T>(XElement, string, IProgress<object>, bool, object[])
Generates an object of type T from an XML element. This overload discards the relative file path output.
public static T Gen<T>(XElement src, string baseDirectory, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class
Parameters
srcXElementThe source XML element
baseDirectorystringThe base directory for resolving paths
progressIProgress<object>Progress reporter for the XML parsing chain
enableRebaseboolWhether to rebase the directory to the file's location
resobject[]Additional parameters for generation
Returns
- T
The generated object of type T
Type Parameters
TThe type of object to generate
Gen<T>(XElement, string, out string, IProgress<object>, bool, object[])
Generates an object of type T from an XML element.
public static T Gen<T>(XElement src, string baseDirectory, out string relFile, IProgress<object> progress, bool enableRebase = true, object[] res = null) where T : class
Parameters
srcXElementThe source XML element
baseDirectorystringThe base directory for resolving paths
relFilestringOutput parameter that receives the relative file path if src is a file reference, or null otherwise
progressIProgress<object>Progress reporter for the XML parsing chain
enableRebaseboolWhether to rebase the directory to the file's location
resobject[]Additional parameters for generation
Returns
- T
The generated object of type T
Type Parameters
TThe type of object to generate