private XElement BuildSimpleType(Type type, out string fileGroup) { var xsdSimpleType = XsdSimpleType.Get(type); //添加XSD文件 fileGroup = xsdSimpleType.FileGroup; SetDefaultFile(fileGroup); var simpleTypeElement = new XElement( _xs + "simpleType", new XAttribute("name", type.Name), new XAttribute("final", "restriction") ); var restrictionElement = new XElement( _xs + "restriction", new XAttribute("base", "xs:string") ); foreach (var val in Enum.GetNames(type)) { restrictionElement.Add( new XElement( _xs + "enumeration", new XAttribute("value", val) ) ); } simpleTypeElement.Add(restrictionElement); return(simpleTypeElement); }
public static string GetFileGroup(Type type) { type = GetPropertyType(type); if (type.IsClass) { return(XsdComplexType.Get(type).FileGroup); } if (type.IsEnum) { return(XsdSimpleType.Get(type).FileGroup); } return(null); }