Пример #1
0
 public static DomWriter Create(string fileName, DomWriterSettings settings)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException(nameof(fileName));
     }
     return(Create(StreamContext.FromFile(fileName), settings));
 }
Пример #2
0
        public DefaultDomWriter(TextWriter writer, DomWriterSettings settings) : base(settings)
        {
            _writer = writer;

            _spaceAroundAttributeEqual = WriterSettings.Indent ? " " : "";
            _quoteChar = WriterSettings.QuoteAttributesCharacter.ToChar();
            _state     = new DomWriterStateMachine();
        }
Пример #3
0
        internal static string GetInnerString(DomWriterSettings settings, DomNode node)
        {
            var sw     = new StringWriter();
            var writer = new DefaultDomWriter(sw, settings);

            writer.Write(node.ChildNodes);
            return(sw.ToString());
        }
Пример #4
0
        public DomWriter CreateWriter(TextWriter writer, DomWriterSettings settings)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            return(CreateDomWriter(writer, settings));
        }
Пример #5
0
        public static DomWriter Create(StreamContext output, DomWriterSettings settings)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }
            var provider = DomProviderFactory.ForFileName(settings, Utility.LocalPath(output.Uri));

            return(provider.CreateWriter(output.AppendText(), settings));
        }
Пример #6
0
 public DomWriterSettings(DomWriterSettings other)
 {
     if (other == null)
     {
         return;
     }
     IsReadOnly               = other.IsReadOnly;
     IndentWidth              = other.IndentWidth;
     Indent                   = other.Indent;
     AlignAttributes          = other.AlignAttributes;
     QuoteAttributesCharacter = other.QuoteAttributesCharacter;
     IndentCharacter          = other.IndentCharacter;
     EndOfLineCharacters      = other.EndOfLineCharacters;
 }
Пример #7
0
        public static DomWriter Create(TextWriter writer, DomWriterSettings settings)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (settings == null)
            {
                return(Create(XmlWriter.Create(writer)));
            }

            var pro = DomProviderFactory.ForProviderObject(settings) ?? DomProviderFactory.Default;

            return(pro.CreateWriter(writer, settings));
        }
Пример #8
0
        public static DomWriterSettings ReadOnly(DomWriterSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (settings.IsReadOnly)
            {
                return(settings);
            }

            var result = settings.CloneReadOnly();

            result.IsReadOnly = true;
            return(result);
        }
Пример #9
0
 static DomWriterSettings()
 {
     Empty = ReadOnly(new DomWriterSettings());
 }
Пример #10
0
 public DomNodeWriterSettings(DomWriterSettings copyFrom)
 {
 }
Пример #11
0
 public string ToDomString(DomWriterSettings settings)
 {
     return(DomWriter.GetOuterString(settings, this));
 }
Пример #12
0
 protected virtual DomWriter CreateDomWriter(TextWriter textWriter, DomWriterSettings settings)
 {
     return(new DefaultDomWriter(textWriter, settings));
 }
 public DomNodeWriterSettings(DomWriterSettings copyFrom)
 {
 }
Пример #14
0
 protected DomWriter(DomWriterSettings writerSettings)
 {
     DomWriterSettings = writerSettings ?? DomWriterSettings.Empty;
 }
Пример #15
0
 static DomWriterSettings()
 {
     Empty = new DomWriterSettings();
     Empty.MakeReadOnly();
 }