private XmlWriter AddConformanceWrapper(XmlWriter baseWriter) { ConformanceLevel confLevel = ConformanceLevel.Auto; XmlWriterSettings baseWriterSettings = baseWriter.Settings; bool checkValues = false; bool checkNames = false; bool replaceNewLines = false; bool needWrap = false; if (baseWriterSettings == null) { // assume the V1 writer already do all conformance checking; // wrap only if NewLineHandling == Replace or CheckCharacters is true if (_newLineHandling == NewLineHandling.Replace) { replaceNewLines = true; needWrap = true; } if (_checkCharacters) { checkValues = true; needWrap = true; } } else { if (_conformanceLevel != baseWriterSettings.ConformanceLevel) { confLevel = this.ConformanceLevel; needWrap = true; } if (_checkCharacters && !baseWriterSettings.CheckCharacters) { checkValues = true; checkNames = confLevel == ConformanceLevel.Auto; needWrap = true; } if (_newLineHandling == NewLineHandling.Replace && baseWriterSettings.NewLineHandling == NewLineHandling.None) { replaceNewLines = true; needWrap = true; } } XmlWriter writer = baseWriter; if (needWrap) { if (confLevel != ConformanceLevel.Auto) { writer = new XmlWellFormedWriter(writer, this); } if (checkValues || replaceNewLines) { writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, this.NewLineChars); } } if (this.IsQuerySpecific && (baseWriterSettings == null || !baseWriterSettings.IsQuerySpecific)) { // Create QueryOutputWriterV1 if CData sections or DocType need to be tracked writer = new QueryOutputWriterV1(writer, this); } return(writer); }
private XmlWriter AddConformanceWrapper(XmlWriter baseWriter) { ConformanceLevel confLevel = ConformanceLevel.Auto; XmlWriterSettings baseWriterSettings = baseWriter.Settings; bool checkValues = false; bool checkNames = false; bool replaceNewLines = false; bool needWrap = false; if (baseWriterSettings == null) { // assume the V1 writer already do all conformance checking; // wrap only if NewLineHandling == Replace or CheckCharacters is true if (this.newLineHandling == NewLineHandling.Replace) { replaceNewLines = true; needWrap = true; } if (this.checkCharacters) { checkValues = true; needWrap = true; } } else { if (this.conformanceLevel != baseWriterSettings.ConformanceLevel) { confLevel = this.ConformanceLevel; needWrap = true; } if (this.checkCharacters && !baseWriterSettings.CheckCharacters) { checkValues = true; checkNames = confLevel == ConformanceLevel.Auto; needWrap = true; } if (this.newLineHandling == NewLineHandling.Replace && baseWriterSettings.NewLineHandling == NewLineHandling.None) { replaceNewLines = true; needWrap = true; } } XmlWriter writer = baseWriter; if (needWrap) { if (confLevel != ConformanceLevel.Auto) { writer = new XmlWellFormedWriter(writer, this); } if (checkValues || replaceNewLines) { writer = new XmlCharCheckingWriter(writer, checkValues, checkNames, replaceNewLines, this.NewLineChars); } } #if !SILVERLIGHT if (this.IsQuerySpecific && (baseWriterSettings == null || !baseWriterSettings.IsQuerySpecific)) { // Create QueryOutputWriterV1 if CData sections or DocType need to be tracked writer = new QueryOutputWriterV1(writer, this); } #endif return writer; }