我正在向 an 写入一些类属性,XmlSchema
目前我想在<xs:element type="xs:string">
.
是否有一些映射类,所以我不必自己编写switch-case
?
public class Foo
{
public string Bar { get; set; }
}
public void WriteProperty()
{
// get the property that is a string
PropertyInfo barProperty;
XmlSchemaElement barElement;
// I don't want this huge switch case for all basic properties.
switch(barProperty.PropertyType.FullName)
{
case "System.String":
barElement.SchemaTypeName = new QualifiedName("xs:string");
break;
// also for int, and bool, and long....
default:
//do other stuff with types that are not default types
break;
}
}