Я пытаюсь создать xs: schema из любого .net Тип программно. Я знаю, что я мог бы использовать отражение и генерировать его, повторяя публичные свойства, но есть ли встроенный способ?
Пример:
[Serializable]
public class Person
{
[XmlElement(IsNullable = false)] public string FirstName { get; set; }
[XmlElement(IsNullable = false)] public string LastName { get; set; }
[XmlElement(IsNullable = true)] public string PhoneNo { get; set; }
}
Требуемый выход:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Person" type="Person" />
<xs:complexType name="Person">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="FirstName" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="LastName" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="PhoneNo" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>