Inheritance: System.Xml.XmlDocument
コード例 #1
0
        public XmlElementEx([NotNull] XmlElement element, [NotNull] XmlDocumentEx document)
        {
            Assert.ArgumentNotNull(element, "element");
            Assert.ArgumentNotNull(document, "document");

            this.Document = document;
            this.Element  = element;
        }
コード例 #2
0
        public XmlElementEx([NotNull] XmlElement element, [NotNull] XmlDocumentEx document)
        {
            Assert.ArgumentNotNull(element, nameof(element));
            Assert.ArgumentNotNull(document, nameof(document));

            Document = document;
            Element  = element;
        }
コード例 #3
0
        public virtual void Initialize()
        {
            if (!FileSystem.FileSystem.Local.File.Exists(FilePath))
            {
                FileSystem.FileSystem.Local.File.WriteAllText(FilePath, @"<settings version=""1.4"" />");
            }

            UnderlyingDocument = XmlDocumentEx.LoadFile(FilePath);
        }
        public virtual void Initialize()
        {
            if (!FileSystem.FileSystem.Local.File.Exists(this.FilePath))
              {
            FileSystem.FileSystem.Local.File.WriteAllText(this.FilePath, @"<settings version=""1.4"" />");
              }

              this.UnderlyingDocument = XmlDocumentEx.LoadFile(this.FilePath);
        }
コード例 #5
0
        public static string Normalize(string xml)
        {
            var doc           = XmlDocumentEx.LoadXml(xml);
            var stringWriter  = new StringWriter(new StringBuilder());
            var xmlTextWriter = new XmlTextWriter(stringWriter)
            {
                Formatting = Formatting.Indented
            };

            doc.Save(xmlTextWriter);
            return(stringWriter.ToString());
        }
コード例 #6
0
 public new static XmlDocumentEx LoadXml(string xml)
 {
     try
     {
         XmlDocument doc = new XmlDocumentEx();
         doc.LoadXml(xml);
         return((XmlDocumentEx)doc);
     }
     catch (Exception ex)
     {
         Log.Warn("Cannot load xml: {0}. {1}\r\n{2}".FormatWith(xml, ex.Message, Environment.StackTrace), typeof(XmlDocumentEx), ex);
         return(null);
     }
 }
コード例 #7
0
 public static XmlDocumentEx LoadStream(Stream stream)
 {
     try
     {
         XmlDocument doc = new XmlDocumentEx();
         doc.Load(stream);
         return((XmlDocumentEx)doc);
     }
     catch (Exception ex)
     {
         Log.Warn(ex, string.Format("Cannot load xml. {1}\r\n{2}", ex.Message, Environment.StackTrace));
         return(null);
     }
 }
コード例 #8
0
 public new static XmlDocumentEx LoadXml(string xml)
 {
     try
     {
         XmlDocument doc = new XmlDocumentEx();
         doc.LoadXml(xml);
         return((XmlDocumentEx)doc);
     }
     catch (Exception ex)
     {
         Log.Warn(ex, $"Cannot load xml: {xml}. {ex.Message}\r\n{Environment.StackTrace}");
         return(null);
     }
 }
コード例 #9
0
        public static XmlDocumentEx LoadFile([NotNull] string path)
        {
            Assert.ArgumentNotNull(path, "path");
            if (!FileSystem.FileSystem.Local.File.Exists(path))
            {
                throw new FileIsMissingException("The " + path + " doesn't exists");
            }

            var document = new XmlDocumentEx
            {
                FilePath = path
            };

            document.Load(path);
            return(document);
        }
コード例 #10
0
        public static XmlDocumentEx LoadFileSafe([NotNull] string path)
        {
            Assert.ArgumentNotNull(path, "path");

            if (!FileSystem.FileSystem.Local.File.Exists(path))
            {
                return(null);
            }

            var document = new XmlDocumentEx
            {
                FilePath = path
            };

            document.Load(path);
            return(document);
        }