Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / QueryReaderSettings.cs / 1 / QueryReaderSettings.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Xml; namespace System.Xml.Xsl { internal class QueryReaderSettings { private bool validatingReader; private XmlReaderSettings xmlReaderSettings; private XmlNameTable xmlNameTable; private EntityHandling entityHandling; private bool namespaces; private bool normalization; private bool prohibitDtd; private WhitespaceHandling whitespaceHandling; private XmlResolver xmlResolver; public QueryReaderSettings(XmlNameTable xmlNameTable) { Debug.Assert(xmlNameTable != null); xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.NameTable = xmlNameTable; xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document; xmlReaderSettings.XmlResolver = null; xmlReaderSettings.ProhibitDtd = true; xmlReaderSettings.CloseInput = true; } public QueryReaderSettings(XmlReader reader) { #pragma warning disable 618 XmlValidatingReader valReader = reader as XmlValidatingReader; #pragma warning restore 618 if (valReader != null) { // Unwrap validation reader validatingReader = true; reader = valReader.Impl.Reader; } xmlReaderSettings = reader.Settings; if (xmlReaderSettings != null) { xmlReaderSettings = xmlReaderSettings.Clone(); xmlReaderSettings.NameTable = reader.NameTable; xmlReaderSettings.CloseInput = true; xmlReaderSettings.LineNumberOffset = 0; xmlReaderSettings.LinePositionOffset = 0; XmlTextReaderImpl impl = reader as XmlTextReaderImpl; if (impl != null) { xmlReaderSettings.XmlResolver = impl.GetResolver(); } } else { xmlNameTable = reader.NameTable; XmlTextReader xmlTextReader = reader as XmlTextReader; if (xmlTextReader != null) { XmlTextReaderImpl impl = xmlTextReader.Impl; entityHandling = impl.EntityHandling; namespaces = impl.Namespaces; normalization = impl.Normalization; prohibitDtd = impl.ProhibitDtd; whitespaceHandling = impl.WhitespaceHandling; xmlResolver = impl.GetResolver(); } else { entityHandling = EntityHandling.ExpandEntities; namespaces = true; normalization = true; prohibitDtd = true; whitespaceHandling = WhitespaceHandling.All; xmlResolver = null; } } } public XmlReader CreateReader(Stream stream, string baseUri) { XmlReader reader; if (xmlReaderSettings != null) { reader = XmlTextReader.Create(stream, xmlReaderSettings, baseUri); } else { XmlTextReaderImpl readerImpl = new XmlTextReaderImpl(baseUri, stream, xmlNameTable); readerImpl.EntityHandling = entityHandling; readerImpl.Namespaces = namespaces; readerImpl.Normalization = normalization; readerImpl.ProhibitDtd = prohibitDtd; readerImpl.WhitespaceHandling = whitespaceHandling; readerImpl.XmlResolver = xmlResolver; reader = readerImpl; } if (validatingReader) { #pragma warning disable 618 reader = new XmlValidatingReader(reader); #pragma warning restore 618 } return reader; } public XmlNameTable NameTable { get { return xmlReaderSettings != null ? xmlReaderSettings.NameTable : xmlNameTable; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Xml; namespace System.Xml.Xsl { internal class QueryReaderSettings { private bool validatingReader; private XmlReaderSettings xmlReaderSettings; private XmlNameTable xmlNameTable; private EntityHandling entityHandling; private bool namespaces; private bool normalization; private bool prohibitDtd; private WhitespaceHandling whitespaceHandling; private XmlResolver xmlResolver; public QueryReaderSettings(XmlNameTable xmlNameTable) { Debug.Assert(xmlNameTable != null); xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.NameTable = xmlNameTable; xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document; xmlReaderSettings.XmlResolver = null; xmlReaderSettings.ProhibitDtd = true; xmlReaderSettings.CloseInput = true; } public QueryReaderSettings(XmlReader reader) { #pragma warning disable 618 XmlValidatingReader valReader = reader as XmlValidatingReader; #pragma warning restore 618 if (valReader != null) { // Unwrap validation reader validatingReader = true; reader = valReader.Impl.Reader; } xmlReaderSettings = reader.Settings; if (xmlReaderSettings != null) { xmlReaderSettings = xmlReaderSettings.Clone(); xmlReaderSettings.NameTable = reader.NameTable; xmlReaderSettings.CloseInput = true; xmlReaderSettings.LineNumberOffset = 0; xmlReaderSettings.LinePositionOffset = 0; XmlTextReaderImpl impl = reader as XmlTextReaderImpl; if (impl != null) { xmlReaderSettings.XmlResolver = impl.GetResolver(); } } else { xmlNameTable = reader.NameTable; XmlTextReader xmlTextReader = reader as XmlTextReader; if (xmlTextReader != null) { XmlTextReaderImpl impl = xmlTextReader.Impl; entityHandling = impl.EntityHandling; namespaces = impl.Namespaces; normalization = impl.Normalization; prohibitDtd = impl.ProhibitDtd; whitespaceHandling = impl.WhitespaceHandling; xmlResolver = impl.GetResolver(); } else { entityHandling = EntityHandling.ExpandEntities; namespaces = true; normalization = true; prohibitDtd = true; whitespaceHandling = WhitespaceHandling.All; xmlResolver = null; } } } public XmlReader CreateReader(Stream stream, string baseUri) { XmlReader reader; if (xmlReaderSettings != null) { reader = XmlTextReader.Create(stream, xmlReaderSettings, baseUri); } else { XmlTextReaderImpl readerImpl = new XmlTextReaderImpl(baseUri, stream, xmlNameTable); readerImpl.EntityHandling = entityHandling; readerImpl.Namespaces = namespaces; readerImpl.Normalization = normalization; readerImpl.ProhibitDtd = prohibitDtd; readerImpl.WhitespaceHandling = whitespaceHandling; readerImpl.XmlResolver = xmlResolver; reader = readerImpl; } if (validatingReader) { #pragma warning disable 618 reader = new XmlValidatingReader(reader); #pragma warning restore 618 } return reader; } public XmlNameTable NameTable { get { return xmlReaderSettings != null ? xmlReaderSettings.NameTable : xmlNameTable; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BitmapDownload.cs
- Label.cs
- HostTimeoutsElement.cs
- AnimationLayer.cs
- TemplatedMailWebEventProvider.cs
- SemanticResultKey.cs
- AliasExpr.cs
- Cursors.cs
- FileLevelControlBuilderAttribute.cs
- XmlSchemaInfo.cs
- ArgumentNullException.cs
- BitmapEffectInput.cs
- BaseTemplateParser.cs
- Metadata.cs
- CloudCollection.cs
- SecureConversationServiceElement.cs
- JsonDeserializer.cs
- MtomMessageEncodingBindingElement.cs
- HttpBrowserCapabilitiesWrapper.cs
- TextTreeUndo.cs
- IndexingContentUnit.cs
- sqlmetadatafactory.cs
- TrimSurroundingWhitespaceAttribute.cs
- MetadataSource.cs
- IdentifierService.cs
- HandlerFactoryWrapper.cs
- QilScopedVisitor.cs
- TreeNodeCollection.cs
- DesignerHelpers.cs
- StandardCommands.cs
- XPathNodeInfoAtom.cs
- ManagementOptions.cs
- TextAdaptor.cs
- ArrayElementGridEntry.cs
- DbDataAdapter.cs
- ArraySet.cs
- ChildTable.cs
- SqlDataSourceCustomCommandPanel.cs
- ConfigurationSectionGroup.cs
- Activity.cs
- SessionEndingCancelEventArgs.cs
- ChannelRequirements.cs
- HasCopySemanticsAttribute.cs
- ProfileEventArgs.cs
- CollectionView.cs
- SymbolType.cs
- ActivityTrace.cs
- InputLanguageEventArgs.cs
- SqlTypeSystemProvider.cs
- Empty.cs
- sitestring.cs
- CompilationUtil.cs
- Vector3D.cs
- MouseWheelEventArgs.cs
- ApplicationActivator.cs
- MetafileHeader.cs
- JsonFormatReaderGenerator.cs
- ToolStripItemImageRenderEventArgs.cs
- CompilerCollection.cs
- DBDataPermission.cs
- HtmlLink.cs
- CompensationDesigner.cs
- Expander.cs
- CodeDomConfigurationHandler.cs
- HttpModuleActionCollection.cs
- SaveFileDialog.cs
- IgnoreFlushAndCloseStream.cs
- BaseAddressPrefixFilterElement.cs
- TemplatePartAttribute.cs
- WSDualHttpSecurityElement.cs
- DesignTimeTemplateParser.cs
- QilLoop.cs
- EventProviderWriter.cs
- WebPartZone.cs
- MemoryFailPoint.cs
- KeyFrames.cs
- ApplicationSettingsBase.cs
- GenericNameHandler.cs
- ToolboxComponentsCreatingEventArgs.cs
- CodeParameterDeclarationExpressionCollection.cs
- EdmFunction.cs
- AsyncDataRequest.cs
- SerializationEventsCache.cs
- WebResponse.cs
- MethodCallTranslator.cs
- DetailsViewInsertedEventArgs.cs
- EditorResources.cs
- DataContractSerializerOperationBehavior.cs
- NumberFormatInfo.cs
- handlecollector.cs
- coordinator.cs
- ActiveXSerializer.cs
- ProfessionalColorTable.cs
- TraceXPathNavigator.cs
- ContentIterators.cs
- MemberDomainMap.cs
- WebDescriptionAttribute.cs
- XamlFilter.cs
- DesignTimeDataBinding.cs
- FormatException.cs