XHelper
This static class holds various methods that are useful in saving and loading model data to and from Linq for XML XElements.
方法
Attribute(XName, IEnumerable<double>, IEnumerable<double>) : XAttribute
Generate an XAttribute for a sequence of Double values, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, double, double) : XAttribute
Generate an XAttribute for a Double value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, Guid, Guid) : XAttribute
Generate an XAttribute for a Guid value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, IEnumerable<int>, IEnumerable<int>) : XAttribute
Generate an XAttribute for a sequence of Int32 values, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, decimal, decimal) : XAttribute
Generate an XAttribute for a Decimal value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, Point, Point) : XAttribute
Generate an XAttribute for a Point value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, int, int) : XAttribute
Generate an XAttribute for an Int32 value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, Thickness, Thickness) : XAttribute
Generate an XAttribute for a Thickness value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, Size, Size) : XAttribute
Generate an XAttribute for a Size value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, bool, bool) : XAttribute
Generate an XAttribute for a Boolean value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, IEnumerable<Point>, IEnumerable<Point>) : XAttribute
Generate an XAttribute for a sequence of Point values, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, DateTime, DateTime) : XAttribute
Generate an XAttribute for a DateTime value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, string, string) : XAttribute
Generate an XAttribute for a String value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, Rect, Rect) : XAttribute
Generate an XAttribute for a Rect value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute(XName, TimeSpan, TimeSpan) : XAttribute
Generate an XAttribute for a TimeSpan value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
AttributeEnum``1(XName, T, T)
Generate an XAttribute for an enumerated type value, unless the value is equal to the given default value.
- n
- the attribute name, often the same as the data's property name
- v
- the property value
- defval
- the default value for the property
返回值: an XAttribute or null
Attribute``1(XName, T, T, Func<T, string>)
This generic method produces an XAttribute with the given value if the value is not equal to the given default value, using the given conversion function to convert the value to a string.
- n
- the name of the XAttribute
- v
- the value
- defval
- the default value for this attribute/property
- conv
- a function from to String
返回值: an XAttribute, or null if the value is null or if it is equal to the default value
Elements``1(XName, XName, IEnumerable, Func<T, string>)
Generate an XElement containing nested child XElements, one for each item in the given collection.
- n
- the name for the new XElement
- c
- the name for the child elements
- v
- conv
返回值: an XElement or null if the given collection was null or empty
Read(XName, XElement, double) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Double, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, IEnumerable<int>) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Thickness, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, TimeSpan) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a TimeSpan, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, int) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to an Int32, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, Point) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Point, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, IEnumerable<double>) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Thickness, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, DateTime) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a DateTime, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, bool) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Boolean, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, Size) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Size, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, string) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a String, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, Thickness) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Thickness, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, IEnumerable<Point>) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Thickness, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, Rect) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Rect, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, Guid) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Guid, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
Read(XName, XElement, decimal) : IEnumerable<Point>
Consume an XAttribute on an XElement, converting the attribute's value to a Decimal, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the expected data type, or the default value
ReadElements``1(XContainer, XName, ICollection<T>, Func<string, T>)
Consume an XContainer that is assumed to hold a collection of nested child XElements each holding a value to be converted to the given data type.
- e
- the XContainer to be read
- c
- the name of the child elements
- coll
- an empty collection to which items are added
- conv
- a conversion function from String to the item data type,
返回值: the collection, containing all of the data items that were read
ReadEnum``1(XName, XElement, T)
Consume an XAttribute on an XElement, converting the attribute's value to an enumerated type, or return the default value if the attribute is not present or if there is a conversion exception.
- n
- the attribute name, often the same as the data's property name
- e
- the XElement holding the expected attribute
- defval
- the default value for the property
返回值: the attribute value converted to the , or the default value
Read``1(XName, XElement, T, Func<string, T>)
This generic method produces a property value from an XElement's attribute value, using a conversion function to convert the string to the expected type, and returning a default value if the conversion fails.
- n
- the name of the attribute
- e
- the XElement that may have an XAttribute with the name
- defval
- the default value to return if there's no attribute named or if the attribute value string cannot be converted to the value type
- conv
- a function from String to
返回值: either the attribute value string converted to , or else the
ToIEnumerableOfDouble(string) : IEnumerable<double>
This data conversion function converts a String to a sequence of Doubles.
- s
ToIEnumerableOfInt32(string) : IEnumerable<int>
This data conversion function converts a String to a sequence of Int32.
- s
ToIEnumerableOfPoint(string) : IEnumerable<Point>
This data conversion function converts a String to a sequence of Points.
- s
ToString(IEnumerable<Point>) : string
This data conversion function converts a sequence of Point values to a String.
- v
ToString(string) : string
This data conversion function converts a String to a String by just returning its argument.
- v
ToString(IEnumerable<double>) : string
This data conversion function converts a sequence of Double values to a String.
- v
ToString(IEnumerable<int>) : string
This data conversion function converts a sequence of Int32 values to a String.
- v