/// <summary> /// Initializes a new instance of the <see cref="XmlEntityAttribute" /> class. /// </summary> /// <param name="mappingNodeName">Name of the mapping node.</param> /// <param name="baseNodeXPath">The base node X path.</param> /// <param name="xmlEntityFlag">The XML entity flag.</param> /// <exception cref="System.Exception">节点名称不能为空。</exception> public XmlEntityAttribute(string mappingNodeName, string baseNodeXPath, XmlEntityFlags xmlEntityFlag) { if (string.IsNullOrEmpty(mappingNodeName.Trim())) { throw new Exception("映射的节点名称不能为空。"); } //设置节点的映射名称 Name = mappingNodeName; //设置节点的标记 XmlEntityFlag = xmlEntityFlag; switch (xmlEntityFlag) { case XmlEntityFlags.Base: case XmlEntityFlags.Base | XmlEntityFlags.Multiple: case XmlEntityFlags.Base | XmlEntityFlags.Single: case XmlEntityFlags.Nested | XmlEntityFlags.Base: case XmlEntityFlags.Nested | XmlEntityFlags.Base | XmlEntityFlags.Multiple: case XmlEntityFlags.Nested | XmlEntityFlags.Base | XmlEntityFlags.Single: case XmlEntityFlags.Nested: case XmlEntityFlags.Nested | XmlEntityFlags.Single: case XmlEntityFlags.Nested | XmlEntityFlags.Multiple: XPath = CheckXPath(baseNodeXPath); break; default: throw new Exception("不合法的实体类型标记或者标记组合,标记:" + xmlEntityFlag); } }
/// <summary> /// Initializes a new instance of the <see cref="XmlEntityAttribute" /> class. /// </summary> /// <param name="mappingNodeName">Name of the mapping node.</param> /// <param name="xmlEntityType">Type of the XML entity.</param> /// <exception cref="System.Exception">节点名称不能为空。</exception> public XmlEntityAttribute(string mappingNodeName, XmlEntityFlags xmlEntityType) : this(mappingNodeName, string.Empty, xmlEntityType) { }