【发布时间】:2022-11-26 06:46:45
【问题描述】:
我正在寻找一种将模式转换为 .NET 核心中的 C# 类的方法。 在 .NET 框架中,我使用 XmlCodeExporter 类来实现此目的,但似乎尚未移植到 .NET 例如,这是一个简单的 shema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="sometype">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="somestring" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="sometype" nillable="true" type="sometype" />
</xs:schema>
我可以运行 xsd 工具来生成以下类:xsd.exe Schema.xsd /c
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
public partial class sometype {
private string somestringField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string somestring {
get {
return this.somestringField;
}
set {
this.somestringField = value;
}
}
}
我怎样才能以编程方式实现这一目标?
在此先感谢您提供的任何帮助
【问题讨论】: