private void WriteType(StreamWriter writer, CSharpType type) { if (!string.IsNullOrEmpty(type.Comment)) { WriteTypeComment(writer, type.Comment); } if (type.Array != null) { WriteArrayTypeHeader(writer, type); } else if (type.Enum != null) { WriteEnumTypeHeader(writer, type); if (type.Enum.EnumValues != null) { for (int i = 0; i < type.Enum.EnumValues.Count; i++) { bool last = i == type.Enum.EnumValues.Count - 1; var enumMember = type.Enum.EnumValues[i]; WriteEnumMember(writer, enumMember, last); } } } else { WriteTypeHeader(writer, type); if (type.Properties != null) { for (int i = 0; i < type.Properties.Count; i++) { var property = type.Properties[i]; WriteProperty(writer, property, i); } } } WriteTypeFooter(writer); }
private void WriteTypeHeader(StreamWriter writer, CSharpType type) { writer.WriteLine(Tab(1) + "[DataContract(Namespace = \"{0}\")]", this.XmlNamespace); writer.WriteLine(Tab(1) + "public class {0}", type.Name); writer.WriteLine(Tab(1) + "{"); }
private void WriteArrayTypeHeader(StreamWriter writer, CSharpType type) { writer.WriteLine(Tab(1) + "[CollectionDataContract(Namespace = \"{0}\", ItemName = \"{1}\")]", this.XmlNamespace, type.Array.ItemName); writer.WriteLine(Tab(1) + "public class {0}", type.Name); writer.WriteLine(Tab(1) + "{"); }