Class XmlAttributeReader
Metadata atributes provider. Uses XML document to describe attributes and their bindings.
public class XmlAttributeReader : IMetadataReader
- Inheritance
-
XmlAttributeReader
- Implements
- Inherited Members
- Extension Methods
Examples
XML format:
<[Root]> <Type Name="<Type.FullName|Type.Name>"> <Member Name="<Name>"> [<Attribute />]* </Member> [<Attribute />]* </Type> </[Root]>
- Root node name could be any
- Type nodes define entity classes with entity type name specified in Name attribute (must be
typeof(Entity).FullName
ortypeof(Entity).Name
value) - Member nodes define entity class members with mapping attributes with member name specified in Name attribute
- Attr nodes define attributes of entity (if nested into Type node) or entity member (when nested into Member node)
Attribute node format:
<[AttributeTypeName]> <[PropertyName] Value="<serialized_value>" Type="<Type.FullName|Type.Name>" /> </[AttributeTypeName]>
- Node name is a mapping attribute type name as
Type.FullName
,Type.Name
orType.Name
without"Attribute"
suffix - PropertyName node name is a name of attribute property you want to set
- Type attribute specify value type as
Type.FullName
orType.Name
string and specified only for non-string properties - Value contains attribute property value, serialized as string, understandable by ChangeType(object?, Type, MappingSchema?, ConversionType) method
Constructors
XmlAttributeReader(Stream)
Creates metadata provider instance.
public XmlAttributeReader(Stream xmlDocStream)
Parameters
xmlDocStream
StreamStream with XML document.
XmlAttributeReader(string)
Creates metadata provider instance.
public XmlAttributeReader(string xmlFile)
Parameters
xmlFile
stringParameter could reference to (probed in specified order):
- full or relative path to XML file resolved against current directory
- full or relative path to XML file resolved against application's app domain base directory (BaseDirectory)
- name of resource with XML document, resolved using GetManifestResourceStream(string) method
- name of resource suffix (
.{
) for resource with XML document, resolved using GetManifestResourceStream(string) methodxmlFile
}
XmlAttributeReader(string, Assembly)
Creates metadata provider instance.
public XmlAttributeReader(string xmlFile, Assembly assembly)
Parameters
xmlFile
stringParameter could reference to (probed in specified order):
- full or relative path to XML file resolved against current directory
- full or relative path to XML file resolved against application's app domain base directory (BaseDirectory)
- name of resource with XML document, resolved using GetManifestResourceStream(string) method
- name of resource suffix (
.{
) for resource with XML document, resolved using GetManifestResourceStream(string) methodxmlFile
}
assembly
AssemblyAssembly to load resource from for two last options from
xmlFile
parameter.
Methods
GetAttributes(Type)
public MappingAttribute[] GetAttributes(Type type)
Parameters
type
Type
Returns
GetAttributes(Type, MemberInfo)
public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
Parameters
type
TypememberInfo
MemberInfo
Returns
GetDynamicColumns(Type)
public MemberInfo[] GetDynamicColumns(Type type)
Parameters
type
Type
Returns
GetObjectID()
public string GetObjectID()