public static XmlWriter Create(XmlWriter output, XmlWriterSettings settings) { if (settings == null) { settings = new XmlWriterSettings(); } else { settings = settings.Clone(); } var src = output.Settings; if (src == null) { settings.ConformanceLevel = ConformanceLevel.Document; // Huh? Why?? output = new DefaultXmlWriter(output); #if NET_4_5 settings.SetReadOnly(); #endif output.settings = settings; } else { ConformanceLevel dst = src.ConformanceLevel; switch (src.ConformanceLevel) { case ConformanceLevel.Auto: dst = settings.ConformanceLevel; break; case ConformanceLevel.Document: case ConformanceLevel.Fragment: if (settings.ConformanceLevel != ConformanceLevel.Auto) { dst = settings.ConformanceLevel; } break; } settings.MergeFrom(src); #if NET_4_5 settings.SetReadOnly(); #endif // It returns a new XmlWriter instance if 1) Settings is null, or 2) Settings ConformanceLevel (or might be other members as well) give significant difference. if (src.ConformanceLevel != dst) { output = new DefaultXmlWriter(output, false); output.settings = settings; } } return(output); }
public static XmlWriter Create(XmlWriter writer, XmlWriterSettings settings) { if (settings == null) { settings = new XmlWriterSettings(); } else { settings = settings.Clone(); } var src = writer.Settings; if (src == null) { settings.ConformanceLevel = ConformanceLevel.Document; // Huh? Why?? writer = new DefaultXmlWriter(writer); writer.settings = settings; } else { ConformanceLevel dst = src.ConformanceLevel; switch (src.ConformanceLevel) { case ConformanceLevel.Auto: dst = settings.ConformanceLevel; break; case ConformanceLevel.Document: case ConformanceLevel.Fragment: if (settings.ConformanceLevel != ConformanceLevel.Auto) { dst = settings.ConformanceLevel; } break; } settings.MergeFrom(src); // It returns a new XmlWriter instance if 1) Settings is null, or 2) Settings ConformanceLevel (or might be other members as well) give significant difference. if (src.ConformanceLevel != dst) { writer = new DefaultXmlWriter(writer, false); writer.settings = settings; } } return(writer); }
public static XmlWriter Create (XmlWriter writer, XmlWriterSettings settings) { if (settings == null) settings = new XmlWriterSettings (); else settings = settings.Clone (); var src = writer.Settings; if (src == null) { settings.ConformanceLevel = ConformanceLevel.Document; // Huh? Why?? writer = new DefaultXmlWriter (writer); writer.settings = settings; } else { ConformanceLevel dst = src.ConformanceLevel; switch (src.ConformanceLevel) { case ConformanceLevel.Auto: dst = settings.ConformanceLevel; break; case ConformanceLevel.Document: case ConformanceLevel.Fragment: if (settings.ConformanceLevel != ConformanceLevel.Auto) dst = settings.ConformanceLevel; break; } settings.MergeFrom (src); // It returns a new XmlWriter instance if 1) Settings is null, or 2) Settings ConformanceLevel (or might be other members as well) give significant difference. if (src.ConformanceLevel != dst) { writer = new DefaultXmlWriter (writer, false); writer.settings = settings; } } return writer; }
public static XmlWriter Create (XmlWriter output, XmlWriterSettings settings) { if (settings == null) settings = new XmlWriterSettings (); else settings = settings.Clone (); var src = output.Settings; if (src == null) { settings.ConformanceLevel = ConformanceLevel.Document; // Huh? Why?? output = new DefaultXmlWriter (output); #if NET_4_5 settings.SetReadOnly (); #endif output.settings = settings; } else { ConformanceLevel dst = src.ConformanceLevel; switch (src.ConformanceLevel) { case ConformanceLevel.Auto: dst = settings.ConformanceLevel; break; case ConformanceLevel.Document: case ConformanceLevel.Fragment: if (settings.ConformanceLevel != ConformanceLevel.Auto) dst = settings.ConformanceLevel; break; } settings.MergeFrom (src); #if NET_4_5 settings.SetReadOnly (); #endif // It returns a new XmlWriter instance if 1) Settings is null, or 2) Settings ConformanceLevel (or might be other members as well) give significant difference. if (src.ConformanceLevel != dst) { output = new DefaultXmlWriter (output, false); output.settings = settings; } } return output; }