Table of Contents

Class XFactory

Namespace
Hi.Common.XmlUtils
Assembly
HiGeom.dll

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

Dictionary<string, XFactory.GenByXElementDelegate>

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

src XElement
baseDirectory string
progress IProgress<object>
enableRebase bool
res object[]

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

src XElement

The parent XML element containing the child to process

baseDirectory string

The base directory for resolving paths

relFile string

Output parameter that receives the relative file path if src is a file reference, or null otherwise

progress IProgress<object>

Progress reporter for the XML parsing chain

enableRebase bool

Whether to rebase the directory to the file's location

res object[]

Additional parameters for generation

Returns

T

The generated object of type T, or null if src is null

Type Parameters

T

The 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

baseDirectory string

The base directory for resolving paths

relFile string

The relative file path to the XML file

progress IProgress<object>

Progress reporter for the XML parsing chain

enableRebase bool

Whether to rebase the directory to the file's location

res object[]

Additional parameters for generation

Returns

T

The generated object of type T, or null if relFile is null

Type Parameters

T

The 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

src XElement
baseDirectory string
progress IProgress<object>
enableRebase bool
res object[]

Returns

FileRefSource<T>

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

baseDirectory string
relFile string
progress IProgress<object>
enableRebase bool
res object[]

Returns

FileRefSource<T>

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

src XElement
baseDirectory string
progress IProgress<object>
enableRebase bool
res object[]

Returns

FileRefSource<T>

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

src XElement

The source XML element

baseDirectory string

The base directory for resolving paths

progress IProgress<object>

Progress reporter for the XML parsing chain

enableRebase bool

Whether to rebase the directory to the file's location

res object[]

Additional parameters for generation

Returns

T

The generated object of type T

Type Parameters

T

The 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

src XElement

The source XML element

baseDirectory string

The base directory for resolving paths

relFile string

Output parameter that receives the relative file path if src is a file reference, or null otherwise

progress IProgress<object>

Progress reporter for the XML parsing chain

enableRebase bool

Whether to rebase the directory to the file's location

res object[]

Additional parameters for generation

Returns

T

The generated object of type T

Type Parameters

T

The type of object to generate