using System.ComponentModel; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; namespace GeoSigma.SigmaDrawerStyle { /// /// 文件导入,其它信息 /// public class OtherInfoProperty : IPropertyFileImport { private IRectangularCSGridPropertyChange iChange; /// /// Initializes a new instance of the class. /// public OtherInfoProperty() { } /// /// Initializes a new instance of the class. /// /// iChange public OtherInfoProperty(IRectangularCSGridPropertyChange iChange) { } [Browsable(false)] public string ColumnLength { get; set; } [Category("\t其他"), DisplayName("\t\t\t\t\t层位")] public string Horizon { get; set; } [Category("\t其他"), DisplayName("\t\t\t\t\t\t类型")] public PointInfos PointType { get; set; } public enum PointInfos { 点类信息, 散点数据, } /// /// 输出Xml数据 /// /// string public string SerialXml() { string strData = string.Empty; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = "\r\n"; settings.Encoding = Encoding.Default; // 去除xml声明 settings.OmitXmlDeclaration = true; System.IO.MemoryStream mem = new MemoryStream(); using (XmlWriter writer = XmlWriter.Create(mem, settings)) { //去除默认命名空间xmlns:xsd和xmlns:xsi XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); XmlSerializer formatter = new XmlSerializer(this.GetType()); formatter.Serialize(writer, this, ns); } return Encoding.Default.GetString(mem.ToArray()); } } }